Inno Setup:TInputQueryWizardPage上的组合框

时间:2017-08-01 05:59:40

标签: inno-setup

我使用Inno Setup为我的程序创建setup.exe。我想获得MS SQL Server中现有数据库的下拉列表(组合框)。但我不知道,我需要使用哪个自定义向导页面。我创建了带有服务器授权的向导页面。

如何做到最好?我的代码:

[Code]
var
  ServerDetailsPage: TInputQueryWizardPage;

procedure InitializeWizard;
begin
  ServerDetailsPage := CreateInputQueryPage(wpSelectDir, 
    '', '', 'Please enter following data (SERVER) and click Next.');
  ServerDetailsPage.Add('IP Address (SERVER)', False);
  ServerDetailsPage.Add('Port Number (SERVER', False);
  ServerDetailsPage.Add('Domain Name\User Name (SERVER)', False);
  ServerDetailsPage.Add('Password (SERVER)', True);
  ServerDetailsPage.Values[0] := '';
  ServerDetailsPage.Values[1] := '';
  ServerDetailsPage.Values[2] := '';
  ServerDetailsPage.Values[3] := '';
end;

1 个答案:

答案 0 :(得分:2)

没有带组合框的现成自定义页面。

您必须使用组合框(TPasswordEdit)替换编辑框(TNewComboBox)。

Multi-line edit in Inno Setup on page created by CreateInputQueryPage类似,代码如下:

var
  ServerDetailsPage: TInputQueryWizardPage;
  ServerComboBox: TNewComboBox;

procedure InitializeWizard;
begin
  ServerDetailsPage :=
    CreateInputQueryPage(
      wpSelectDir, '', '', 'Please enter following data (SERVER) and click Next.');
  ServerDetailsPage.Add('IP Address (SERVER)', False);
  ServerDetailsPage.Add('Port Number (SERVER', False);
  ServerDetailsPage.Add('Domain Name\User Name (SERVER)', False);
  ServerDetailsPage.Add('Password (SERVER)', True);
  ServerDetailsPage.Values[0] := '';
  ServerDetailsPage.Values[1] := '';
  ServerDetailsPage.Values[2] := '';
  ServerDetailsPage.Values[3] := '';

  { Create TNewComboBox on the same parent control and the same location as edit box }
  ServerComboBox := TNewComboBox.Create(ServerDetailsPage);
  ServerComboBox.Parent := ServerDetailsPage.Edits[0].Parent;
  ServerComboBox.Left := ServerDetailsPage.Edits[0].Left;
  ServerComboBox.Top := ServerDetailsPage.Edits[0].Top;
  ServerComboBox.Width := ServerDetailsPage.Edits[0].Width;
  ServerComboBox.Height := ServerDetailsPage.Edits[0].Height;
  ServerComboBox.TabOrder := ServerDetailsPage.Edits[0].TabOrder;
  ServerComboBox.Items.Add('server1');
  ServerComboBox.Items.Add('server2');

  { Hide the original edit box }
  ServerDetailsPage.PromptLabels[0].FocusControl := ServerComboBox;

  { Link the label to the combo box }
  { (has a practical effect only if there were a keyboard accelerator on the label) }
  ServerDetailsPage.Edits[0].Visible := False;
end;

现在,要引用组合框值,您当然不能再使用ServerDetailsPage.Values[0]了。请改用ServerComboBox.Text

enter image description here