Replacing Inno Setup installation type combo box with radio buttons on separate page (Install Shield like)

前端 未结 1 1344
野趣味
野趣味 2020-12-10 00:19

I am using Inno Setup generate installer for my application.

To enable user for selecting full or compact installation, I use the following code,

         


        
相关标签:
1条回答
  • 2020-12-10 01:02

    One way is to implement a custom page with "types" menu, hide the standard "types" combo box, and update its selection based on a type a user selected in the custom menu.

    [Types]
    Name: "typical"; Description: "Typical installation"
    Name: "complete"; Description: "Complete installation"
    Name: "custom"; Description: "Custom installation"; Flags: iscustom
    
    [Components]
    Name: "main"; Description: "Main Files"; Types: complete typical custom; Flags: fixed
    Name: "help"; Description: "Help Files"; Types: complete
    Name: "help\english"; Description: "English"; Types: complete
    Name: "help\dutch"; Description: "Dutch"; Types: complete
    
    [Code]
    
    var
      TypesPage: TWizardPage;
      TypicalButton: TNewRadioButton;
      CompleteButton: TNewRadioButton;
      CustomButton: TNewRadioButton;
    
    procedure InitializeWizard();
    begin
      { Create custom "types" page }
      TypesPage :=
        CreateCustomPage(
          wpSelectDir, 'Setup Type', 'Choose the setup type that best suits your needs.');
    
      TypicalButton := TNewRadioButton.Create(TypesPage);
      TypicalButton.Parent := TypesPage.Surface;
      TypicalButton.Caption := 'Typical';
      TypicalButton.Height := ScaleY(TypicalButton.Height);
      TypicalButton.Checked := True; { default, unless other type is selected below }
    
      CompleteButton := TNewRadioButton.Create(TypesPage);
      CompleteButton.Parent := TypesPage.Surface;
      CompleteButton.Caption := 'Complete';
      CompleteButton.Height := ScaleY(CompleteButton.Height);
      CompleteButton.Top := TypicalButton.Top + TypicalButton.Height + ScaleY(16);
      CompleteButton.Checked := (WizardForm.TypesCombo.ItemIndex = 1);
    
      CustomButton := TNewRadioButton.Create(TypesPage);
      CustomButton.Parent := TypesPage.Surface;
      CustomButton.Caption := 'Custom';
      CustomButton.Height := ScaleY(CustomButton.Height);
      CustomButton.Top := CompleteButton.Top + CompleteButton.Height + ScaleY(16);
      CompleteButton.Checked := (WizardForm.TypesCombo.ItemIndex = 2);
    
      { Hide "types" combo }
      WizardForm.TypesCombo.Visible := False;
      WizardForm.IncTopDecHeight(WizardForm.ComponentsList,
        -(WizardForm.ComponentsList.Top - WizardForm.TypesCombo.Top));
    end;
    
    function NextButtonClick(CurPageID: Integer): Boolean;
    begin
      { When leaving "types" page, update hidden "types" combo box }
      { according to user selection... }
      if CurPageID = TypesPage.ID then
      begin
        if CompleteButton.Checked then WizardForm.TypesCombo.ItemIndex := 1
          else 
        if CustomButton.Checked then WizardForm.TypesCombo.ItemIndex := 2
          else WizardForm.TypesCombo.ItemIndex := 0;
        { .. and have Inno Setup update components selection accordingly }
        WizardForm.TypesCombo.OnChange(WizardForm.TypesCombo);
      end;
      Result := True;
    end;
    
    function ShouldSkipPage(PageID: Integer): Boolean;
    begin
      { Skip "components" page, unless "custom" type was selected }
      Result := (PageID = wpSelectComponents) and (not CustomButton.Checked);
    end;
    


    To add additional images and labels, see:
    Inno Setup Placing image/control on custom page


    For an alternative implementation, that shows the radio buttons on "Select Components" page, see:
    Replace installation types Dropdown list by radio buttons

    0 讨论(0)
提交回复
热议问题