source: cprs/trunk/CPRS-Chart/fAResize.pas@ 893

Last change on this file since 893 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

File size: 2.3 KB
Line 
1unit fAResize;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
7 fPage, ExtCtrls, VA508AccessibilityManager;
8
9type
10 TfrmAutoResize = class(TfrmPage)
11 procedure FormDestroy(Sender: TObject);
12 procedure FormResize(Sender: TObject);
13 private
14 FSizes: TList;
15 protected
16 procedure Loaded; override;
17 end;
18
19var
20 frmAutoResize: TfrmAutoResize;
21
22implementation
23
24uses VA508AccessibilityRouter;
25
26{$R *.DFM}
27
28type
29 TSizeRatio = class // records relative sizes and positions for resizing logic
30 CLeft: Extended;
31 CTop: Extended;
32 CWidth: Extended;
33 CHeight: Extended;
34 constructor Create(ALeft, ATop, AWidth, AHeight: Extended);
35 end;
36
37{ TSizeRatio methods }
38
39constructor TSizeRatio.Create(ALeft, ATop, AWidth, AHeight: Extended);
40begin
41 CLeft := ALeft; CTop := ATop; CWidth := AWidth; CHeight := AHeight;
42end;
43
44{ TfrmAutoResize methods }
45
46procedure TfrmAutoResize.Loaded;
47{ record initial size & position info for resizing logic }
48var
49 SizeRatio: TSizeRatio;
50 i,H,W: Integer;
51begin
52 FSizes := TList.Create;
53 H := ClientHeight;
54 W := ClientWidth;
55 for i := 0 to ControlCount - 1 do with Controls[i] do
56 begin
57 SizeRatio := TSizeRatio.Create(Left/W, Top/H, Width/W, Height/H);
58 FSizes.Add(SizeRatio);
59 end;
60 inherited Loaded;
61end;
62
63procedure TfrmAutoResize.FormResize(Sender: TObject);
64{ resize child controls using their design time proportions }
65var
66 SizeRatio: TSizeRatio;
67 i,H,W: Integer;
68begin
69 inherited;
70 H := Height;
71 W := Width;
72 with FSizes do for i := 0 to ControlCount - 1 do
73 begin
74 SizeRatio := Items[i];
75 with SizeRatio do
76 if Controls[i] is TLabel then with Controls[i] do
77 SetBounds(Round(CLeft*W), Round(CTop*H), Width, Height)
78 else
79 Controls[i].SetBounds(Round(CLeft*W), Round(CTop*H), Round(CWidth*W), Round(CHeight*H));
80 end; {with FSizes}
81end;
82
83procedure TfrmAutoResize.FormDestroy(Sender: TObject);
84{ destroy objects used to record size and position information for controls }
85var
86 SizeRatio: TSizeRatio;
87 i: Integer;
88begin
89 inherited;
90 with FSizes do for i := 0 to Count-1 do
91 begin
92 SizeRatio := Items[i];
93 SizeRatio.Free;
94 end;
95 FSizes.Free;
96end;
97
98
99initialization
100 SpecifyFormIsNotADialog(TfrmAutoResize);
101
102
103end.
Note: See TracBrowser for help on using the repository browser.