Джирайя
Джирайя

Reputation: 159

Inno Setup: Combo box on TInputQueryWizardPage

I create setup.exe for my program using Inno Setup. I want to get a drop down list (combo box) of existing databases in MS SQL Server. But I don't know, what custom wizard page I need to use. I created wizard page with authorization for servers.

How best to do it? My code:

[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;

Upvotes: 3

Views: 3773

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202642

There's no ready-made custom page with combo boxes.

You have to replace the edit box (TPasswordEdit) with a combo box (TNewComboBox).

Similarly to Multi-line edit in Inno Setup on page created by CreateInputQueryPage, the code would be like:

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;

Now, to refer to combo box value, you, of course, cannot use ServerDetailsPage.Values[0] anymore. Use ServerComboBox.Text instead.


enter image description here

Upvotes: 5

Related Questions