我最近添加不同的安装类型(安装,更新,维修),以我的InnoSetup。 这一切都workes相当优良。
[Types]
Name: Install; Description: "Install OLP";
Name: Update; Description: "Update an existing version of OLP";
Name: Repair; Description: "Repair OLP";
我不喜欢那么多的唯一的事情是下拉列表中,当安装运行,选择安装类型之一出现。
有没有办法通过一个单选按钮组,以取代下拉列表?
谢谢
您可以使用单选按钮(因为有在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;
而结果(包括iscustom
组件列表):
或者你可以使用如检查列表框,这是能够包含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;
而结果(包括iscustom
组件列表):
这方面的一个整洁的解决办法是使用CreateInputOptionPage
创建具有前的组件选择页面单选按钮一个单独的页面。 (有这个在CodeDlg.iss脚本的例子。)
一个更整洁的选择是不问可言,因为它是完全不必要的。 您可以自动检测到已经安装的版本 - 如果不是安装它,它的安装,如果它安装,但年纪大了,这是一个升级,如果它的安装和相同的版本,那么它是一个修复,最后如果它安装,但新那么它是一个降级 - 你可能想要么禁止(更安全),或者许可证,但显示警告(更方便,如果很可能是人们可能要降级)。