-
Notifications
You must be signed in to change notification settings - Fork 5
/
MainForm.pas
210 lines (133 loc) · 4.66 KB
/
MainForm.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
UNIT MainForm;
{-------------------------------------------------------------------------------------------------------------
This application will demonstrate:
1. How to save the state of all GUI controls on application shutdown and then restore them loaded on application startup:
* checkboxes
* radiobuttons
* cubic custom controls
* form's position
* controls on the second form
2. How to send messages to the AppLog
This demo app requires the Cubic Light Saber library.
-------------------------------------------------------------------------------------------------------------}
INTERFACE
USES
WinApi.Windows, WinApi.Messages, System.SysUtils, System.Classes, Vcl.StdCtrls, VCL.Forms, Vcl.Controls,
Vcl.ExtCtrls, Vcl.Samples.Spin, Vcl.ComCtrls, System.Actions, Vcl.ActnList, Vcl.Menus, Vcl.Dialogs,
ccCore, ccINIFile, FormLog, clRichLogTrack;
TYPE
TfrmTester = class(TForm)
FontDialog: TFontDialog;
GroupBox1: TGroupBox;
chkAutoSave: TCheckBox;
radShow: TRadioButton;
MainMenu: TMainMenu;
File1: TMenuItem;
Autosave1: TMenuItem;
ActionList: TActionList;
actAutoSave: TAction;
GroupBox2: TGroupBox;
Button4: TButton;
Button3: TButton;
btnShowLog: TButton;
Button2: TButton;
actSaveGUI: TAction;
actLoadGui: TAction;
SaveGUItoINI1: TMenuItem;
LoadGUIfromINI1: TMenuItem;
radShowNot: TRadioButton;
Button1: TButton;
btnLoad: TButton;
Button5: TButton;
procedure FormCreate (Sender: TObject);
procedure FormDestroy (Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure actAutoSaveExecute(Sender: TObject);
procedure btnShowLogClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure actSaveGUIExecute(Sender: TObject);
procedure actLoadGuiExecute(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
procedure LateInitialize(VAR message: TMessage); message MSG_LateInitialize;
public
end;
VAR
frmTester: TfrmTester;
IMPLEMENTATION {$R *.dfm}
USES
ccAppData, ccIO, ccINIFileVCL, SecondForm;
{--------------------------------------------------------------------------------------------------
APP START/CLOSE
--------------------------------------------------------------------------------------------------}
procedure TfrmTester.FormCreate(Sender: TObject);
begin
PostMessage(Self.Handle, MSG_LateInitialize, 0, 0); { This will call LateInitialize }
end;
procedure TfrmTester.LateInitialize;
begin
LoadForm(frmTester);
LoadForm(frmContainer);
if AppRunningFirstTime
then MesajInfo(
'This application will demonstrate:'+ CRLF+
CRLF+
'1. How to save the state of all GUI controls on application shutdown and then restore them loaded on application startup:'+ CRLF+
'* checkboxes'+ CRLF+
'* radiobuttons'+ CRLF+
'* cubic custom controls'+ CRLF+
'* form''s position'+ CRLF+
'* controls on the second form'+ CRLF+
CRLF+
'2. How to send messages to the AppLog');
if radShow.Checked
then Button5Click(Self);
AppInitializing:= FALSE;
LogAddImpo('Application started ok.');
end;
//todo 1: the log's trackbar is not saved!
procedure TfrmTester.FormDestroy(Sender: TObject);
begin
LogAddWarn('Application shutting down...');
if actAutoSave.Checked
then SaveForm(Self);
ReleaseLogForm;
end;
procedure TfrmTester.actSaveGUIExecute(Sender: TObject);
begin
SaveForm(Self);
end;
procedure TfrmTester.actLoadGuiExecute(Sender: TObject);
begin
LoadForm(Self);
end;
procedure TfrmTester.btnShowLogClick(Sender: TObject);
begin
ShowLog;
end;
procedure TfrmTester.actAutoSaveExecute(Sender: TObject);
begin
//The status of this action (autocheck) will be stored to the ini file also
end;
procedure TfrmTester.Button2Click(Sender: TObject);
begin
if FontDialog.Execute
then Font:= FontDialog.Font;
end;
procedure TfrmTester.Button3Click(Sender: TObject);
begin
LogAddVerb('Some less important information');
MesajInfo('You need to set log''s verbosity to "verbose" in order to see this message.');
end;
procedure TfrmTester.Button4Click(Sender: TObject);
begin
LogAddError('Error encountered!');
end;
procedure TfrmTester.Button5Click(Sender: TObject);
begin
frmContainer.grpContainer.Parent:= Self;
frmContainer.grpContainer.Align:= alBottom;
end;
end.
.3