1
votes

I am using Inno Setup generate installer for my application.

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

[Types]
Name: "full"; Description: "Full Installation"
Name: "compact"; Description: "Lite Installation"
Name: "custom"; Description: "Custom Installation"; Flags: iscustom

[Components]
Name: "One"; Description: "First"; Types: full compact custom; Flags: fixed
Name: "Two"; Description: "second"; Types: full
Name: "Three"; Description: "Third"; Types: full
Name: "Four"; Description: "Fourth"; Types: full
Name: "Five"; Description: "Fifth"; Types: full

And I get the following UI:

enter image description here

Is there any possibility to change this way (via combo-box) of selecting the "Type"?

I want "Type" selection like on an example below. And if user selects custom he should be able to select which "Components" to install.

enter image description here

1

1 Answers

3
votes

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;

enter image description here

enter image description here


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