source: Common/Demo/PersistentForm/Unit1.pas

Last change on this file was 563, checked in by chronos, 18 months ago
  • Modified: Removed U prefix from all Common package units.
File size: 2.5 KB
Line 
1unit Unit1;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, XMLConf, FileUtil, Forms, Controls, Graphics, Dialogs,
9 Buttons, StdCtrls, ExtCtrls, ComCtrls, Menus, XMLPropStorage, PersistentForm;
10
11type
12
13 { TForm1 }
14
15 TForm1 = class(TForm)
16 ListView1: TListView;
17 PersistentForm1: TPersistentForm;
18 Timer1: TTimer;
19 XMLConfig1: TXMLConfig;
20 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
21 procedure FormResize(Sender: TObject);
22 procedure FormShow(Sender: TObject);
23 procedure Timer1Timer(Sender: TObject);
24 private
25 procedure AddValue(Name, Value: string);
26 public
27 { public declarations }
28 procedure ShowDimensions;
29 end;
30
31var
32 Form1: TForm1;
33
34const
35 WindowStateText: array[TWindowState] of string = ('wsNormal', 'wsMinimized',
36 'wsMaximized', 'wsFullScreen');
37
38implementation
39
40{$R *.lfm}
41
42{ TForm1 }
43
44procedure TForm1.FormShow(Sender: TObject);
45begin
46 PersistentForm1.Load(Self);
47end;
48
49procedure TForm1.Timer1Timer(Sender: TObject);
50begin
51 ShowDimensions;
52end;
53
54procedure TForm1.AddValue(Name, Value: string);
55var
56 NewItem: TListItem;
57begin
58 NewItem := ListView1.Items.Add;
59 NewItem.Caption := Name;
60 NewItem.SubItems.Add(Value);
61end;
62
63procedure TForm1.ShowDimensions;
64begin
65 with ListView1.Items do begin
66 Clear;
67 AddValue('Form.Left', IntToStr(Self.Left));
68 AddValue('Form.Top', IntToStr(Self.Top));
69 AddValue('Form.Width', IntToStr(Self.Width));
70 AddValue('Form.Height', IntToStr(Self.Height));
71 AddValue('Form.RestoredLeft', IntToStr(Self.RestoredLeft));
72 AddValue('Form.RestoredTop', IntToStr(Self.RestoredTop));
73 AddValue('Form.RestoredWidth', IntToStr(Self.RestoredWidth));
74 AddValue('Form.RestoredHeight', IntToStr(Self.RestoredHeight));
75 AddValue('Form.BoundsRect.Left', IntToStr(Self.BoundsRect.Left));
76 AddValue('Form.BoundsRect.Top', IntToStr(Self.BoundsRect.Top));
77 AddValue('Form.BoundsRect.Right', IntToStr(Self.BoundsRect.Right));
78 AddValue('Form.BoundsRect.Bottom', IntToStr(Self.BoundsRect.Bottom));
79 AddValue('Screen.DesktopLeft', IntToStr(Screen.DesktopLeft));
80 AddValue('Screen.DesktopTop', IntToStr(Screen.DesktopTop));
81 AddValue('Screen.DesktopWidth', IntToStr(Screen.DesktopWidth));
82 AddValue('Screen.DesktopHeight', IntToStr(Screen.DesktopHeight));
83 AddValue('WindowState', WindowStateText[Self.WindowState]);
84 end;
85end;
86
87procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
88begin
89 PersistentForm1.Save(Self);
90end;
91
92procedure TForm1.FormResize(Sender: TObject);
93begin
94 ShowDimensions;
95end;
96
97end.
98
Note: See TracBrowser for help on using the repository browser.