-
Notifications
You must be signed in to change notification settings - Fork 140
/
listSelectDlg.pas
49 lines (41 loc) · 1.1 KB
/
listSelectDlg.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
unit listSelectDlg;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, CheckLst, types, utilLib, strutils;
type
TlistSelectFrm = class(TForm)
listBox: TCheckListBox;
Panel1: TPanel;
okBtn: TButton;
cancelBtn: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
function listSelect(title:string; var options:TstringList):boolean;
implementation
{$R *.dfm}
function listSelect(title:string; var options:TstringList):boolean;
var
dlg: TlistSelectFrm;
i: integer;
begin
result:=FALSE;
dlg:=TlistSelectFrm.Create(NIL);
with dlg do
try
caption:=title;
listBox.items.assign(options);
for i:=0 to options.count-1 do
if options.objects[i] <> NIL then
listbox.Checked[i]:=TRUE;
clientHeight:=clientHeight-listBox.ClientHeight+listBox.ItemHeight*minmax(5,15, listbox.count);
if showModal() = mrCancel then exit;
for i:=0 to listbox.Count-1 do
options.Objects[i]:=if_(listbox.Checked[i], PTR1, NIL);
result:=TRUE;
finally dlg.free end;
end;
end.