-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDebugOptions.pas
112 lines (94 loc) · 2.59 KB
/
DebugOptions.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
(*
* GExperts Debug Window Interface
* http://www.gexperts.org
*
* You are free to use this code in any application to send commands to the
* GExperts debug window. This includes usage in commercial, shareware,
* freeware, public domain, and other applications.
*)
//
// Baz Cuda, 2022: Renamed, rejigged, camelhumped and augmented.
// All credit rests with the original authors for this very handy tool.
unit DebugOptions;
interface
uses
Windows, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls;
type
TDebugConfigData = class(TObject)
public
Start: Boolean;
OnMessage: Boolean;
Bottom: Boolean;
constructor Create;
procedure SaveSettings;
procedure LoadSettings;
end;
type
TfmDebugOptions = class(TForm)
gbxView: TGroupBox;
chkShowOnStartup: TCheckBox;
chkShowOnMessage: TCheckBox;
gbxMessages: TGroupBox;
chkNewAtBottom: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
procedure FormCreate(Sender: TObject);
procedure btnOKClick(Sender: TObject);
end;
var
ConfigInfo: TDebugConfigData = nil;
fmDebugOptions: TfmDebugOptions;
implementation
uses Registry{, GX_GenericUtils}; // BAZ
{$R *.dfm}
constructor TDebugConfigData.Create;
begin
inherited Create;
LoadSettings;
end;
procedure TDebugConfigData.LoadSettings;
var
Settings: TRegIniFile;
begin
Settings := TRegIniFile.Create('Software\Baz\Debug'); // Do not localize
try
Start := Settings.ReadBool('View', 'startup', False);
OnMessage := Settings.ReadBool('View', 'onMessage', TRUE);
Bottom := Settings.ReadBool('Messages', 'bottom', False);
finally
FreeAndNil(Settings);
end;
end;
procedure TDebugConfigData.SaveSettings;
var
Settings: TRegIniFile;
begin
Settings := TRegIniFile.Create('Software\Baz\Debug');
try
Settings.WriteBool('View', 'startup', Start);
Settings.WriteBool('View', 'onMessage', OnMessage);
Settings.WriteBool('Messages', 'bottom', Bottom);
finally
FreeAndNil(Settings);
end;
end;
procedure TfmDebugOptions.FormCreate(Sender: TObject);
begin
// SetDefaultFont(Self); // BAZ
chkShowOnStartup.Checked := ConfigInfo.Start;
chkShowOnMessage.Checked := ConfigInfo.OnMessage;
chkNewAtBottom.Checked := ConfigInfo.Bottom;
end;
procedure TfmDebugOptions.btnOKClick(Sender: TObject);
begin
ConfigInfo.Start := chkShowOnStartup.Checked;
ConfigInfo.OnMessage := chkShowOnMessage.Checked;
ConfigInfo.Bottom := chkNewAtBottom.Checked;
ConfigInfo.SaveSettings;
ModalResult := mrOk;
end;
initialization
ConfigInfo := TDebugConfigData.Create;
finalization
FreeAndNil(ConfigInfo);
end.