source: cprs/branches/tmg-cprs/CPRS-Chart/fAResize.pas@ 1806

Last change on this file since 1806 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

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