Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
547 views
in Technique[技术] by (71.8m points)

inno setup - Replace installation types dropdown list by radio buttons

I recently added different installation types (Install, Update, Repair) to my Inno Setup. It all works pretty fine.

[Types]
Name: Install; Description: "Install OLP"; 
Name: Update; Description: "Update an existing version of OLP"; 
Name: Repair; Description: "Repair OLP"; 

The only thing I do not like so much is the dropdown list, that appears when installation runs, to select one of the installation types.

Is there a way to replace the dropdown list by a radio group?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use radio buttons (since there's no radio group component available in Inno Setup):

[Code]
procedure OnTypeChange(Sender: TObject);
begin
  { set the item index in hidden TypesCombo }
  WizardForm.TypesCombo.ItemIndex := TNewRadioButton(Sender).Tag;
  { notify TypesCombo about the selection change }
  WizardForm.TypesCombo.OnChange(nil);
end;

procedure InitializeWizard;
var
  I: Integer;
  RadioButton: TNewRadioButton;
begin
  for I := 0 to WizardForm.TypesCombo.Items.Count - 1 do
  begin
    { create radio button and set the basic properties }
    RadioButton := TNewRadioButton.Create(WizardForm);
    RadioButton.Parent := WizardForm.SelectComponentsPage;
    RadioButton.Left := WizardForm.TypesCombo.Left;
    RadioButton.Top := WizardForm.TypesCombo.Top + I * RadioButton.Height;
    RadioButton.Width := WizardForm.TypesCombo.Width;
    { check just the first item }
    RadioButton.Checked := I = 0;
    RadioButton.Caption := WizardForm.TypesCombo.Items[I];
    { the Tag property substitutes the index property }
    RadioButton.Tag := I;
    RadioButton.TabOrder := I;     
    RadioButton.OnClick := @OnTypeChange;
  end;
  { hide the TypesCombo combo box }
  WizardForm.TypesCombo.Visible := False;

  { if you're not using the "iscustom" flag in any type entry, you can remove }
  { the following lines, because they resize and reposition the check list box }
  { for component selection, which is hidden, if you don't use "iscustom" flag }
  I := WizardForm.ComponentsList.Top - 
    (RadioButton.Top + RadioButton.Height + 8);
  WizardForm.ComponentsList.Top := RadioButton.Top + RadioButton.Height + 8;
  WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height + I;
end;

And the result (includes the iscustom component list):

enter image description here

Or you can use e.g. check list box, which is able to contain radio buttons in Inno Setup:

[Code]
procedure OnTypeChange(Sender: TObject);
begin
  { set the item index in hidden TypesCombo }
  WizardForm.TypesCombo.ItemIndex := TNewCheckListBox(Sender).ItemIndex;
  { notify TypesCombo about the selection change }
  WizardForm.TypesCombo.OnChange(nil);
end;

procedure InitializeWizard;
var
  I: Integer;
  CheckListBox: TNewCheckListBox;
begin
  { create the TNewCheckListBox object and set the basic properties }
  CheckListBox := TNewCheckListBox.Create(WizardForm);
  CheckListBox.Parent := WizardForm.SelectComponentsPage;
  CheckListBox.Left := WizardForm.TypesCombo.Left;
  CheckListBox.Top := WizardForm.TypesCombo.Top;
  CheckListBox.Width := WizardForm.TypesCombo.Width;
  CheckListBox.Height := CheckListBox.MinItemHeight * 
    WizardForm.TypesCombo.Items.Count + 4;
  CheckListBox.TabOrder := 0;
  { assign the selection change event }
  CheckListBox.OnClickCheck := @OnTypeChange;
  { add radio buttons from all TypesCombo items, select the first item }
  for I := 0 to WizardForm.TypesCombo.Items.Count - 1 do
    CheckListBox.AddRadioButton(WizardForm.TypesCombo.Items[I], 
      '', 0, I = 0, True, nil);
  { hide the TypesCombo combo box }
  WizardForm.TypesCombo.Visible := False;

  { if you're not using the "iscustom" flag in any type entry, you can remove }
  { the following lines, because they resize and reposition the check list box }
  { for component selection, which is hidden, if you don't use "iscustom" flag }
  I := WizardForm.ComponentsList.Top - 
    (CheckListBox.Top + CheckListBox.Height + 8);
  WizardForm.ComponentsList.Top := CheckListBox.Top + 
    CheckListBox.Height + 8;
  WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height + I;
end;

And the result (includes the iscustom component list):

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...