-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingFrm.pas
104 lines (90 loc) · 2.3 KB
/
SettingFrm.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
unit SettingFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Spin, StdCtrls, ConfigUnit, Registry;
type
TSettingForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
Label4: TLabel;
SpinEdit1: TSpinEdit;
Label5: TLabel;
CheckBox1: TCheckBox;
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
FDirty: Boolean;
public
{ Public declarations }
end;
var
SettingForm: TSettingForm;
implementation
{$R *.dfm}
procedure TSettingForm.Button1Click(Sender: TObject);
procedure AutoRun(IsRun: Boolean);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
if Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', False) then
begin
if IsRun then
Reg.WriteString('BugFreeHelper', Application.ExeName)
else
Reg.WriteString('BugFreeHelper', '');
end;
finally
Reg.Free;
end;
end;
begin
Config.BugFreeUrl := Edit1.Text;
Config.UserName := Edit2.Text;
Config.UserPWD := Edit3.Text;
Config.UpdateIntervalSec := SpinEdit1.Value;
Config.AutoStart := CheckBox1.Checked;
Config.Save;
AutoRun(Config.AutoStart);
FDirty := False;
// MessageBox(Application.Handle, '参数已经保存!', '提示', MB_OK + MB_ICONINFORMATION);
Close;
end;
procedure TSettingForm.Button2Click(Sender: TObject);
begin
if FDirty then
begin
if MessageBox(Application.Handle, '数据被修改,是否放弃修改?', '提示', MB_YESNO + MB_ICONQUESTION) = ID_YES then
begin
Close;
Exit;
end
else Exit;
end;
Close;
end;
procedure TSettingForm.Edit1Change(Sender: TObject);
begin
FDirty := True;
end;
procedure TSettingForm.FormShow(Sender: TObject);
begin
Edit1.Text := Config.BugFreeUrl;
Edit2.Text := Config.UserName;
Edit3.Text := Config.UserPWD;
SpinEdit1.Value := Config.UpdateIntervalSec;
CheckBox1.Checked := Config.AutoStart;
FDirty := False;
end;
end.