2
0

CompInputQueryCombo.pas 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. unit CompInputQueryCombo;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2020 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. InputQuery with a TComboBox instead of a TEdit
  8. }
  9. interface
  10. uses
  11. Classes, Controls, StdCtrls, UIStateForm;
  12. type
  13. TInputQueryCombo = class(TUIStateForm)
  14. OKButton: TButton;
  15. CancelButton: TButton;
  16. PromptLabel: TLabel;
  17. ValueComboBox: TComboBox;
  18. procedure FormCreate(Sender: TObject);
  19. private
  20. function GetValue: String;
  21. procedure SetPrompt(const APrompt: String);
  22. procedure SetValue(const AValue: String);
  23. procedure SetValues(const AValues: TStringList);
  24. public
  25. property Prompt: String write SetPrompt;
  26. property Value: String read GetValue write SetValue;
  27. property Values: TStringList write SetValues;
  28. end;
  29. function InputQueryCombo(const ACaption, APrompt: String; var AValue: String; const AValues: TStringList): Boolean;
  30. implementation
  31. uses
  32. Windows, Messages, CompFunc, Forms;
  33. {$R *.DFM}
  34. function InputQueryCombo(const ACaption, APrompt: String; var AValue: String; const AValues: TStringList): Boolean;
  35. begin
  36. with TInputQueryCombo.Create(Application) do try
  37. Caption := ACaption;
  38. Prompt := APrompt;
  39. Value := AValue;
  40. Values := AValues;
  41. if ShowModal = mrOk then begin
  42. AValue := Value;
  43. Result := True;
  44. end else
  45. Result := False;
  46. finally
  47. Free;
  48. end;
  49. end;
  50. procedure TInputQueryCombo.FormCreate(Sender: TObject);
  51. begin
  52. InitFormFont(Self);
  53. end;
  54. function TInputQueryCombo.GetValue: String;
  55. begin
  56. Result := ValueComboBox.Text;
  57. end;
  58. procedure TInputQueryCombo.SetPrompt(const APrompt: String);
  59. begin
  60. PromptLabel.Caption := APrompt;
  61. end;
  62. procedure TInputQueryCombo.SetValue(const AValue: String);
  63. begin
  64. ValueComboBox.Text := AValue;
  65. end;
  66. procedure TInputQueryCombo.SetValues(const AValues: TStringList);
  67. begin
  68. ValueComboBox.Items := AValues;
  69. end;
  70. end.