forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompInputQueryCombo.pas
86 lines (70 loc) · 1.98 KB
/
CompInputQueryCombo.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
unit CompInputQueryCombo;
{
Inno Setup
Copyright (C) 1997-2020 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
InputQuery with a TComboBox instead of a TEdit
}
interface
uses
Classes, Controls, StdCtrls, UIStateForm;
type
TInputQueryCombo = class(TUIStateForm)
OKButton: TButton;
CancelButton: TButton;
PromptLabel: TLabel;
ValueComboBox: TComboBox;
procedure FormCreate(Sender: TObject);
private
function GetValue: String;
procedure SetPrompt(const APrompt: String);
procedure SetValue(const AValue: String);
procedure SetValues(const AValues: TStringList);
public
property Prompt: String write SetPrompt;
property Value: String read GetValue write SetValue;
property Values: TStringList write SetValues;
end;
function InputQueryCombo(const ACaption, APrompt: String; var AValue: String; const AValues: TStringList): Boolean;
implementation
uses
Windows, Messages, CompFunc, Forms;
{$R *.DFM}
function InputQueryCombo(const ACaption, APrompt: String; var AValue: String; const AValues: TStringList): Boolean;
begin
with TInputQueryCombo.Create(Application) do try
Caption := ACaption;
Prompt := APrompt;
Value := AValue;
Values := AValues;
if ShowModal = mrOk then begin
AValue := Value;
Result := True;
end else
Result := False;
finally
Free;
end;
end;
procedure TInputQueryCombo.FormCreate(Sender: TObject);
begin
InitFormFont(Self);
end;
function TInputQueryCombo.GetValue: String;
begin
Result := ValueComboBox.Text;
end;
procedure TInputQueryCombo.SetPrompt(const APrompt: String);
begin
PromptLabel.Caption := APrompt;
end;
procedure TInputQueryCombo.SetValue(const AValue: String);
begin
ValueComboBox.Text := AValue;
end;
procedure TInputQueryCombo.SetValues(const AValues: TStringList);
begin
ValueComboBox.Items := AValues;
end;
end.