This repository was archived by the owner on Mar 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUConfig.pas
More file actions
128 lines (112 loc) · 3.12 KB
/
UConfig.pas
File metadata and controls
128 lines (112 loc) · 3.12 KB
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
unit UConfig;
interface
uses
Forms, StdCtrls, SysUtils, Controls, Classes, Windows, shlobj,
Config;
type
TConfigForm = class(TForm)
ButtonOk: TButton;
ButtonCancel: TButton;
EditPort: TEdit;
Label1: TLabel;
CheckBoxIconize: TCheckBox;
EditFolder: TEdit;
Label4: TLabel;
ButtonFolder: TButton;
EditUser: TEdit;
EditPassword: TEdit;
Label2: TLabel;
Label3: TLabel;
EditAdminIp: TEdit;
Label5: TLabel;
CheckBoxAcceptGateway: TCheckBox;
EditBackDates: TEdit;
Label6: TLabel;
procedure Show(Sender: TObject);
procedure ButtonOkClick(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
procedure ButtonFolderClick(Sender: TObject);
function SelectFolderDialog(owner: HWND; Title: string): AnsiString;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FLocalConfig: TConfig;
end;
implementation
uses
StrSub;
{$R *.dfm}
procedure TConfigForm.FormCreate(Sender: TObject);
begin
FLocalConfig := TConfig.Create;
end;
procedure TConfigForm.FormDestroy(Sender: TObject);
begin
FLocalConfig.Free;
end;
procedure TConfigForm.Show(Sender: TObject);
begin
FLocalConfig.Load;
EditPort.Text := FLocalConfig.FPort;
CheckBoxIconize.Checked := FLocalConfig.FIconize;
EditFolder.Text := FLocalConfig.FFolderOrg;
EditUser.Text := FLocalConfig.FUser;
EditPassword.Text := FLocalConfig.FPassword;
EditAdminIp.Text := FLocalConfig.FAdminIp;
EditBackDates.Text := IntToStr(FLocalConfig.FBackDates);
CheckBoxAcceptGateway.Checked := FLocalConfig.FAcceptGateway;
end;
procedure TConfigForm.ButtonOkClick(Sender: TObject);
begin
if EditFolder.Text <> '' then begin
if EditFolder.Text[Length(EditFolder.Text)] = '\' then begin
EditFolder.Text := Copy(EditFolder.Text, 1, Length(EditFolder.Text) - 1);
end;
end;
FLocalConfig.FPort := EditPort.Text;
FLocalConfig.FIconize := CheckBoxIconize.Checked;
FLocalConfig.FFolderOrg := EditFolder.Text;
FLocalConfig.FUser := EditUser.Text;
FLocalConfig.FPassword := EditPassword.Text;
FLocalConfig.FAdminIp := EditAdminIp.Text;
FLocalConfig.FBackDates := StrToInt2(EditBackDates.Text);
FLocalConfig.FAcceptGateway := CheckBoxAcceptGateway.Checked;
FLocalConfig.Save;
ModalResult := mrOK;
end;
procedure TConfigForm.ButtonCancelClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TConfigForm.ButtonFolderClick(Sender: TObject);
var
s: string;
begin
s := SelectFolderDialog(Handle, 'Crescentの実行ファイルのあるフォルダを選んで下さい');
if s <> '' then begin
EditFolder.Text := s;
end;
end;
function TConfigForm.SelectFolderDialog(owner: HWND; Title: string): AnsiString;
var
b: BROWSEINFO ;
path: array[0..MAX_PATH] of char;
id: PItemIDList;
begin
b.hwndOwner := owner;
b.pidlRoot := nil;
b.pszDisplayName := path;
b.lpszTitle := pchar(Title);
b.ulFlags := BIF_RETURNONLYFSDIRS;
b.lpfn := nil;
b.lParam := 0;
b.iImage := 0;
id := SHBrowseForFolder(b);
if id <> nil then begin
SHGetPathFromIDList(id, path);
Result := path;
end else begin
Result := '';
end;
end;
end.