Inno Setup custom page with multiple destination folders that behave like the normal folder select page

前端 未结 2 1391
情话喂你
情话喂你 2020-12-18 11:52

I\'ve the following code (taken from Use two/multiple selected directories from custom page in Files section):

[Co         


        
2条回答
  •  失恋的感觉
    2020-12-18 12:14

    For future reference, here is the full working code based on Martin's answer. Make sure to add "DisableDirPage=yes" to the [Setup] section.

    Note: Due to a bug, the code below works only in the unicode version of InnoSetup.

    [Code]
    var
      DirPage: TInputDirWizardPage;
      HiddenPage: TInputDirWizardPage;
      HiddenPage2: TInputDirWizardPage;
      HiddenPage3: TInputDirWizardPage;
    
    procedure AppendDirBrowseClick(Sender: TObject);
    begin
      HiddenPage.Values[0] := DirPage.Values[0];
      HiddenPage.Buttons[0].OnClick(HiddenPage.Buttons[0]);
      DirPage.Values[0] := HiddenPage.Values[0];
    end;
    
    procedure AppendDirBrowseClick2(Sender: TObject);
    begin
      HiddenPage2.Values[0] := DirPage.Values[1];
      HiddenPage2.Buttons[0].OnClick(HiddenPage2.Buttons[0]);
      DirPage.Values[1] := HiddenPage2.Values[0];
    end;
    
    procedure AppendDirBrowseClick3(Sender: TObject);
    begin
      HiddenPage3.Values[0] := DirPage.Values[2];
      HiddenPage3.Buttons[0].OnClick(HiddenPage3.Buttons[0]);
      DirPage.Values[2] := HiddenPage3.Values[0];
    end;
    
    function SkipPage(Sender: TWizardPage): Boolean;
    begin
      Result := True;
    end;
    
    procedure InitializeWizard();
    begin
      DirPage := CreateInputDirPage(
        wpSelectDir, SetupMessage(msgWizardSelectDir), '', '', False, '');
    
      DirPage.Add('Path to Apache:');
      DirPage.Add('Path to PHP:');
      DirPage.Add('Path to Server Files:');
    
      { assign default directories for the items from the previously stored data; if }
      { there are no data stored from the previous installation, use default folders }
      { of your choice }
      DirPage.Values[0] := GetPreviousData('Directory1', 'C:\Apache');
      DirPage.Values[1] := GetPreviousData('Directory2', 'C:\PHP');
      DirPage.Values[2] := GetPreviousData('Directory3', 'C:\Apache\htdocs\Server Files');
    
      DirPage.Buttons[0].OnClick := @AppendDirBrowseClick;
      DirPage.Buttons[1].OnClick := @AppendDirBrowseClick2;
      DirPage.Buttons[2].OnClick := @AppendDirBrowseClick3;
    
      HiddenPage := CreateInputDirPage(
        wpSelectDir, SetupMessage(msgWizardSelectDir), '', '', True, 'Apache');
      HiddenPage.Add('');
      HiddenPage.OnShouldSkipPage := @SkipPage;
    
      HiddenPage2 := CreateInputDirPage(
        wpSelectDir, SetupMessage(msgWizardSelectDir), '', '', True, 'PHP');
      HiddenPage2.Add('');
      HiddenPage2.OnShouldSkipPage := @SkipPage;
    
      HiddenPage3 := CreateInputDirPage(
        wpSelectDir, SetupMessage(msgWizardSelectDir), '', '', True, 'Server Files');
      HiddenPage3.Add('');
      HiddenPage3.OnShouldSkipPage := @SkipPage;
    end;
    

提交回复
热议问题