source: DpiControls/Demo/UFormMain.pas

Last change on this file was 537, checked in by chronos, 5 years ago
File size: 1.3 KB
Line 
1unit UFormMain;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
9 ExtCtrls, UDpiControls, UDpiFormMain;
10
11type
12
13 { TFormMain }
14
15 TFormMain = class(TForm)
16 ButtonNewDpiForm: TButton;
17 Label1: TLabel;
18 Timer1: TTimer;
19 TrackBar1: TTrackBar;
20 procedure ButtonNewDpiFormClick(Sender: TObject);
21 procedure FormDestroy(Sender: TObject);
22 procedure FormShow(Sender: TObject);
23 procedure Timer1Timer(Sender: TObject);
24 procedure TrackBar1Change(Sender: TObject);
25 private
26 DpiForm: TDpiForm;
27 public
28 Redraw: Boolean;
29 end;
30
31var
32 FormMain: TFormMain;
33
34implementation
35
36{$R *.lfm}
37
38{ TFormMain }
39
40procedure TFormMain.FormShow(Sender: TObject);
41begin
42 DpiScreen.Dpi := 96 * 2;
43 TrackBar1.Position := DpiScreen.Dpi;
44 ButtonNewDpiFormClick(nil);
45end;
46
47procedure TFormMain.Timer1Timer(Sender: TObject);
48begin
49 Redraw := False;
50 DpiScreen.Dpi := TrackBar1.Position;
51end;
52
53procedure TFormMain.ButtonNewDpiFormClick(Sender: TObject);
54begin
55 DpiForm := TDpiFormMain.Create(nil);
56 DpiForm.Caption := DpiForm.Name;
57 DpiForm.SetBounds(100, 100, 400, 200);
58 DpiForm.Show;
59 DpiScreen.Forms.Add(DpiForm);
60end;
61
62procedure TFormMain.FormDestroy(Sender: TObject);
63begin
64 FreeAndNil(DpiForm);
65end;
66
67procedure TFormMain.TrackBar1Change(Sender: TObject);
68begin
69 Redraw := True;
70end;
71
72end.
73
Note: See TracBrowser for help on using the repository browser.