1 | unit UDpiFormMain;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, UDpiControls, Dialogs, Graphics;
|
---|
9 |
|
---|
10 | type
|
---|
11 |
|
---|
12 | { TDpiFormMain }
|
---|
13 |
|
---|
14 | TDpiFormMain = class(TDpiForm)
|
---|
15 | DpiPaintBox1: TDpiPaintBox;
|
---|
16 | procedure DpiButton1Click(Sender: TObject);
|
---|
17 | procedure DpiFormMainCreate(Sender: TObject);
|
---|
18 | procedure DpiFormMainDestroy(Sender: TObject);
|
---|
19 | procedure DpiPaintBox1Paint(Sender: TObject);
|
---|
20 | private
|
---|
21 | Button: TDpiButton;
|
---|
22 | Image: TDpiImage;
|
---|
23 | ListBox: TDpiListBox;
|
---|
24 | PaintBox: TDpiPaintBox;
|
---|
25 | public
|
---|
26 |
|
---|
27 | end;
|
---|
28 |
|
---|
29 | var
|
---|
30 | DpiFormMain: TDpiFormMain;
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 | {$R *.lfm}
|
---|
35 |
|
---|
36 | { TDpiFormMain }
|
---|
37 |
|
---|
38 | procedure TDpiFormMain.DpiFormMainCreate(Sender: TObject);
|
---|
39 | var
|
---|
40 | I: Integer;
|
---|
41 | begin
|
---|
42 | Button := TDpiButton.Create(DpiFormMain);
|
---|
43 | Button.Parent := Self;
|
---|
44 | Button.SetBounds(10, 10, 100, 30);
|
---|
45 | Button.Caption := 'Click me';
|
---|
46 | Button.Visible := True;
|
---|
47 |
|
---|
48 | Image := TDpiImage.Create(DpiFormMain);
|
---|
49 | Image.Parent := Self;
|
---|
50 | Image.SetBounds(150, 10, 100, 100);
|
---|
51 | Image.Visible := True;
|
---|
52 | Image.Stretch := True;
|
---|
53 | Image.VclImage.Picture.LoadFromFile('dance.jpg');
|
---|
54 | //Image.Picture.LoadFromFile('dance.jpg');
|
---|
55 |
|
---|
56 | ListBox := TDpiListBox.Create(DpiFormMain);
|
---|
57 | for I := 0 to 10 do
|
---|
58 | ListBox.VclListBox.Items.Add('Item ' + IntToStr(I));
|
---|
59 | ListBox.Parent := Self;
|
---|
60 | ListBox.SetBounds(250, 10, 100, 100);
|
---|
61 | ListBox.Visible := True;
|
---|
62 |
|
---|
63 | DpiPaintBox1.BoundsRect := Rect(0, 0, 100, 100);
|
---|
64 | DpiPaintBox1.VclPaintBox.Parent := VclForm;
|
---|
65 | DpiPaintBox1.Repaint;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TDpiFormMain.DpiFormMainDestroy(Sender: TObject);
|
---|
69 | begin
|
---|
70 | FreeAndNil(Button);
|
---|
71 | FreeAndNil(Image);
|
---|
72 | FreeAndNil(ListBox);
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TDpiFormMain.DpiPaintBox1Paint(Sender: TObject);
|
---|
76 | begin
|
---|
77 | with DpiPaintBox1.Canvas do begin
|
---|
78 | Brush.Color := clWhite;
|
---|
79 | Brush.Style := bsSolid;
|
---|
80 | FillRect(Rect(0, 0, 100, 100));
|
---|
81 | Caption := IntToStr(Width);
|
---|
82 | Pen.Color := clGreen;
|
---|
83 | Pen.Style := psSolid;
|
---|
84 | MoveTo(0, 0);
|
---|
85 | LineTo(100, 100);
|
---|
86 | Font.Color := clRed;
|
---|
87 | TextOut(40, 10, 'Scaled text');
|
---|
88 | end;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | procedure TDpiFormMain.DpiButton1Click(Sender: TObject);
|
---|
92 | begin
|
---|
93 | ShowMessage('Hello');
|
---|
94 | end;
|
---|
95 |
|
---|
96 | end.
|
---|
97 |
|
---|