-
Notifications
You must be signed in to change notification settings - Fork 3
/
UDialog.pas
100 lines (85 loc) · 2.02 KB
/
UDialog.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
unit UDialog;
{$MODE Delphi}
interface
uses
LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfUDialog = class(TForm)
lblMsg: TLabel;
cmdB1: TButton;
cmdB2: TButton;
cmdB3: TButton;
cmdB4: TButton;
cmdB5: TButton;
function SplitStr(var theString: string; delimiter: string): string;
procedure cmdBClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
sMsg, // message to display
sButtons: string; // buttons to display
iDlgResult: integer; // number of button pressed, 0 if form closed with X button
end;
var
fUDialog: TfUDialog;
implementation
{$R *.lfm}
{uses StdPas;}
function TfuDialog.SplitStr(var theString: string; delimiter: string): string;
var
i: integer;
begin
Result:= '';
if theString <> '' then
begin
i:= Pos(delimiter, theString);
if i > 0 then
begin
Result:= Copy(theString, 1, i-1);
theString:= Copy(theString, i+Length(delimiter), maxLongInt);
end
else
begin
Result:= theString;
theString:= '';
end;
end;
end;
procedure TfUDialog.FormShow(Sender: TObject);
var
sBtn: string;
begin
lblMsg.Caption := sMsg;
sBtn := SplitStr(sButtons,';');
cmdB1.Visible := sBtn>'';
cmdB1.Caption := sBtn;
sBtn := SplitStr(sButtons,';');
cmdB2.Visible := sBtn>'';
cmdB2.Caption := sBtn;
sBtn := SplitStr(sButtons,';');
cmdB3.Visible := sBtn>'';
cmdB3.Caption := sBtn;
sBtn := SplitStr(sButtons,';');
cmdB4.Visible := sBtn>'';
cmdB4.Caption := sBtn;
sBtn := SplitStr(sButtons,';');
cmdB5.Visible := sBtn>'';
cmdB5.Caption := sBtn;
iDlgResult := 0;
end;
procedure TfUDialog.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key=#27 then begin
iDlgResult := 0;
Close;
end;
end;
procedure TfUDialog.cmdBClick(Sender: TObject);
begin
iDlgResult := (Sender as Tcontrol).Tag;
Close;
end;
end.