forked from do-/steludio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitSettings.pas
75 lines (61 loc) · 1.83 KB
/
UnitSettings.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
unit UnitSettings;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Registry;
type
TFormSettings = class(TForm)
LabeledEditTabSize: TLabeledEdit;
LabeledEditFontSize: TLabeledEdit;
BitBtnOK: TBitBtn;
BitBtnCancel: TBitBtn;
CheckBoxBold: TCheckBox;
procedure BitBtnOKClick(Sender: TObject);
procedure BitBtnCancelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormSettings: TFormSettings;
implementation
{$R *.dfm}
procedure TFormSettings.BitBtnOKClick (Sender: TObject);
var
Reg: TRegistry;
i, c: integer;
begin
val (LabeledEditTabSize.Text, i, c);
if c > 0 then begin
Application.MessageBox ('Invalid tab size', 'Validation error', mb_iconstop + mb_ok);
ActiveControl := LabeledEditTabSize;
LabeledEditTabSize.SelectAll;
Abort;
end;
val (LabeledEditFontSize.Text, i, c);
if c > 0 then begin
Application.MessageBox ('Invalid font size', 'Validation error', mb_iconstop + mb_ok);
ActiveControl := LabeledEditFontSize;
LabeledEditFontSize.SelectAll;
Abort;
end;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey ('\Software\Eludia\Studio\Settings', True) then begin
Reg.WriteString ('FontSize', LabeledEditFontSize.Text);
Reg.WriteString ('TabWidth', LabeledEditTabSize.Text);
if CheckBoxBold.Checked then Reg.WriteString ('FontBold', '1') else Reg.WriteString ('FontBold', '0');
Reg.CloseKey;
end;
finally
Reg.Free;
end;
ModalResult := mrok;
end;
procedure TFormSettings.BitBtnCancelClick(Sender: TObject);
begin
ModalResult := mrcancel;
end;
end.