How to add two custom pages in Inno Setup?

2019-02-20 19:10发布

问题:

I want to create two authorization for two server in my setup.exe, but I get only one. I use this code:

[Code]
...
procedure InitializeWizard;
begin
    ServerDetailsPage1:= CreateInputQueryPage(wpWelcome, 
      '', '', 'Please enter following data and click Next.');

    ServerDetailsPage1.Add('IP Address (1)', False);                  {0}
    ServerDetailsPage1.Add('Port Number (1)', False);                 {1}
    ServerDetailsPage1.Add('Domain Name\User Name (1)', False);       {2}
    ServerDetailsPage1.Add('Password (1)', True);                     {3}
    ServerDetailsPage1.Values[1] := '';
    ServerDetailsPage1.Values[1] := '\';                     

    ServerDetailsPage2 := CreateInputQueryPage(wpWelcome, 
      '', '', 'Please enter following data for SQL Server and click Next.');

    ServerDetailsPage2.Add('IP Address (2)', False);             {0}
    ServerDetailsPage2.Add('Port Number (2)', False);            {1}
    ServerDetailsPage2.Add('Domain Name\User Name (2)', False);  {2}
    ServerDetailsPage2.Add('Password (2)', True);                {3}
    ServerDetailsPage2.Values[1] := ''; 
    ServerDetailsPage2.Values[2] := '\';
end;

Where is error? Thanks for any idea.

回答1:

Method signature to add CustomInputInqueryPage :

function CreateInputQueryPage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String): TInputQueryWizardPage;

In your case you have passed wpWelcome as AfterID for both pages, ServerDetailsPage1 and ServerDetailsPage2.

If you want to make ServerDetailsPage2 , appear after ServerDetailsPage1, change code as :

ServerDetailsPage2 := CreateInputQueryPage(ServerDetailsPage1.ID, 
  '', '', 'Please enter following data for SQL Server and click Next.');


回答2:

Works for me. I get two pages, as expected.

Maybe you get confused, because you get the "second" page before the "first", because you insert both after the "welcome" page. The page, that you add later, gets inserted before the page, that you add first.

To get them in the correct order, insert the second page after the first one:

ServerDetailsPage2 := CreateInputQueryPage(ServerDetailsPage1.ID, ...);


标签: inno-setup