-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuScaleHelper.pas
More file actions
45 lines (36 loc) · 836 Bytes
/
Copy pathuScaleHelper.pas
File metadata and controls
45 lines (36 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
unit uScaleHelper;
interface
type
ScaleHelper = class
private
class var FPPI: Integer;
/// <summary>
/// Current and last known PPI
/// </summary>
class procedure SetPPI(Value: Integer); static;
public
class property PPI: Integer read FPPI write SetPPI;
end;
implementation
uses
Vcl.Forms, System.SysUtils;
{ ScaleFunctions }
class procedure ScaleHelper.SetPPI(Value: Integer);
var
LCycle: Integer;
begin
if FPPI = 0 then
begin
if FPPI = Value then
raise Exception.Create('Not properly initialized')
else
FPPI := Value;
end;
if Application.MainForm <> nil then
if Application.MainForm.PixelsPerInch <> Value then
Application.MainForm.PixelsPerInch := Value;
for LCycle := 0 to Screen.FormCount - 1 do
Screen.Forms[LCycle].ScaleBy(Value, FPPI);
FPPI := Value;
end;
end.