source: DpiControls/Demo/UDpiFormMain.pas

Last change on this file was 537, checked in by chronos, 5 years ago
File size: 2.0 KB
Line 
1unit UDpiFormMain;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, UDpiControls, Dialogs, Graphics;
9
10type
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
29var
30 DpiFormMain: TDpiFormMain;
31
32implementation
33
34{$R *.lfm}
35
36{ TDpiFormMain }
37
38procedure TDpiFormMain.DpiFormMainCreate(Sender: TObject);
39var
40 I: Integer;
41begin
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;
66end;
67
68procedure TDpiFormMain.DpiFormMainDestroy(Sender: TObject);
69begin
70 FreeAndNil(Button);
71 FreeAndNil(Image);
72 FreeAndNil(ListBox);
73end;
74
75procedure TDpiFormMain.DpiPaintBox1Paint(Sender: TObject);
76begin
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;
89end;
90
91procedure TDpiFormMain.DpiButton1Click(Sender: TObject);
92begin
93 ShowMessage('Hello');
94end;
95
96end.
97
Note: See TracBrowser for help on using the repository browser.