source: trunk/Packages/Common/Demo/PersistentForm/Unit1.pas

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