在单独的页面上用单选按钮替换Inno Setup安装类型组合框(类似Shield的安装) [英] Replacing Inno Setup installation type combo box with radio buttons on separate page (Install Shield like)
问题描述
我正在为我的应用程序使用Inno Setup生成安装程序.
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
我得到以下用户界面:
是否有可能(通过组合框)以这种方式更改选择类型"的方式?
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.
推荐答案
一种方法是使用类型"菜单实现自定义页面,隐藏标准的类型"组合框,然后根据用户的类型更新其选择在自定义菜单中选择.
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;
要添加其他图像和标签,请参阅:
Inno设置将图像/控件放置在自定义页面上
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
这篇关于在单独的页面上用单选按钮替换Inno Setup安装类型组合框(类似Shield的安装)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!