This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
UnitFlagsUnit.pas
82 lines (69 loc) · 1.72 KB
/
UnitFlagsUnit.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
unit UnitFlagsUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst, ExtCtrls;
type
TUnitFlagsForm = class(TForm)
Bevel: TBevel;
btCancel: TButton;
btOK: TButton;
btCheckAll: TButton;
clbMain: TCheckListBox;
procedure FormCreate(Sender: TObject);
procedure btOKClick(Sender: TObject);
procedure btCheckAllClick(Sender: TObject);
private
FFlags: int64;
{ Private declarations }
public
{ Public declarations }
property Flags: int64 read FFlags;
procedure Prepare(Text: string);
procedure Load(What: string);
end;
implementation
uses MyDataModule, Functions;
{$R *.dfm}
{ TUnitFlagsForm }
procedure TUnitFlagsForm.btCheckAllClick(Sender: TObject);
var
i: integer;
begin
FFlags := StrToInt64Def(Text,0);
for i := 0 to clbMain.Items.Count - 1 do
begin
clbMain.Checked[i] := true;
end;
end;
procedure TUnitFlagsForm.btOKClick(Sender: TObject);
var
i: integer;
begin
FFlags := 0;
for i := 0 to clbMain.Items.Count - 1 do
if clbMain.Checked[i] then FFlags := FFlags or (1 shl i);
end;
procedure TUnitFlagsForm.FormCreate(Sender: TObject);
begin
dmMain.Translate.CreateDefaultTranslation(TForm(Self));
dmMain.Translate.TranslateForm(TForm(Self));
end;
procedure TUnitFlagsForm.Load(What: string);
begin
Caption := What;
LoadStringListFromFile(clbMain.Items, What);
if clbMain.Items.Count <= 16 then clbMain.Columns := 1;
end;
procedure TUnitFlagsForm.Prepare(Text: string);
var
i: integer;
begin
FFlags := StrToInt64Def(Text,0);
for i := 0 to clbMain.Items.Count - 1 do
begin
if FFlags and (1 shl i) <> 0 then
clbMain.Checked[i] := true;
end;
end;
end.