-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathugroupedit.pas
129 lines (112 loc) · 2.84 KB
/
ugroupedit.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
// Copyright 2017, Kaj Mikkelsen
// This software is distributed under the GPL 3 license
// The full text of the license can be found in the aboutbox
// as well as in the file "Copying"
unit ugroupedit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TFGroupEdit }
TFGroupEdit = class(TForm)
CheckBox1: TCheckBox;
CheckBox10: TCheckBox;
CheckBox11: TCheckBox;
CheckBox12: TCheckBox;
CheckBox13: TCheckBox;
CheckBox14: TCheckBox;
CheckBox15: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
OKButton: TButton;
CancelButton: TButton;
procedure CancelButtonClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
Groups: string;
end;
var
FGroupEdit: TFGroupEdit;
implementation
{$R *.lfm}
uses
MyLib;
{ TFGroupEdit }
procedure TFGroupEdit.OKButtonClick(Sender: TObject);
var
i: integer;
MyComponent: TComponent;
begin
Groups := '';
for i := 1 to 15 do
begin
MyComponent := FGroupEdit.FindComponent('CheckBox' + IntToStr(i));
if TCheckBox(MyComponent).Checked then
begin
if Groups <> '' then
Groups := Groups + ',';
Groups := Groups + TCheckBox(MyComponent).Caption;
end;
end;
ModalResult := mrOk;
end;
procedure TFGroupEdit.CancelButtonClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TFGroupEdit.FormActivate(Sender: TObject);
var
i, i1: integer;
St: string;
MyComponent: TComponent;
Strl: TStringList;
begin
Strl := TStringList.Create;
if Groups <> '' then
Split(Groups, ',', Strl);
for i := 0 to 14 do
begin
if i < 10 then
St := 'Group0' + IntToStr(i)
else
St := 'Group' + IntToStr(i);
MyComponent := FGroupEdit.FindComponent('CheckBox' + IntToStr(i + 1));
if MyComponent <> nil then
begin
TCheckBox(MyComponent).Caption := GetStdIni('Group', St, '');
TCheckBox(MyComponent).Checked := False;
if TCheckBox(MyComponent).Caption <> '' then
begin
TCheckBox(MyComponent).Enabled := True;
for i1 := 0 to Strl.Count - 1 do
if TCheckBox(MyComponent).Caption = Strl[i1] then
TCheckBox(MyComponent).Checked := True;
end
else
TCheckBox(MyComponent).Enabled := False;
end;
end;
Strl.Free;
end;
procedure TFGroupEdit.FormCreate(Sender: TObject);
begin
RestoreForm(FGroupEdit);
end;
procedure TFGroupEdit.FormDestroy(Sender: TObject);
begin
SaveForm(FGroupEdit);
end;
end.