2017-08-01 281 views
1

我使用Inno Setup的我的程序創建的setup.exe組合框。我想在MS SQL Server中獲得現有數據庫的下拉列表(組合框)。但我不知道,我需要使用哪個自定義嚮導頁面。我創建了具有服務器授權的嚮導頁面。Inno Setup的:在TInputQueryWizardPage

如何最有效地做到這一點?我的代碼:

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

所以你要替換* 「的IP地址(服務器)」 * ** **編輯框用** **組合框,是正確的? –

+0

@馬丁Prikryl,是 –

+0

OK,這是一個問題。獲取MS SQL數據庫列表是另一個問題。單獨詢問。而且它比Inno Setup問題更像MS SQL問題,所以請確保您也標記了它[tag:sql-server]。 –

回答

1

沒有帶組合框的現成定製頁面。

您必須用組合框(TNewComboBox)替換編輯框(TPasswordEdit)。

類似於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

+0

非常感謝你。我尋求它。 –

+0

不客氣。現在你有15的聲望,你也可以upvote有用的帖子:) –

+0

如果你有問題,請在單獨的帖子。不要濫用評論! –