Innosetup新增Wizard Page

Innosetup 新增一个向导页面,让用户选择安装方式

转载于:http://www.docin.com/p-612536939.html

在Innosetup的向导页面中,新增一个页面,提供两种安装选择

1.选择标准安装将跳过“选择目标位置”和“选择开始菜单文件夹”等页面。(主要是跳过部分页面,快捷安装)

2.用户自定义安装,可以选择安装目录等


在[Code]段添加以下代码:


var
     Page: TWizardPage; {定义一个页面,在pascal中大括号是用来注释的}

     RadioButton1, RadioButton2: TRadioButton; {定义2个单选按钮}
     Lbl1, Lbl2: TNewStaticText; {定义两个label,用来阐述安装的信息}


procedure CreateAddonPage;{新建添加页面的方法}
begin
     Page := CreateCustomPage(wpInfoBefore, '选择安装类型', '请根据您的需要选择安装的类型');

    {设置单选按钮1的属性,并添加到页面中}

    RadioButton1 := TRadioButton.Create(Page);
    RadioButton1.Left := ScaleX(80);
    RadioButton1.Top := ScaleY(40);
    RadioButton1.Width := Page.SurfaceWidth;
    RadioButton1.Height := ScaleY(17);
    RadioButton1.Caption := '标准安装';
    RadioButton1.Checked := True;
    RadioButton1.Parent := Page.Surface;

    {设置label1的属性,并添加到页面中}
    Lbl1 := TNewStaticText.Create(Page);
    Lbl1.Left := ScaleX(95);
    Lbl1.Top := ScaleY(60);
    Lbl1.Width := ScaleX(250);
    Lbl1.Height := ScaleY(50);
    Lbl1.Caption := '按照标准模式安装软件到您的电脑';
    Lbl1.Parent := Page.Surface;

    {设置单选按钮2的属性,并添加到页面中}
    RadioButton2 := TRadioButton.Create(Page);
    RadioButton2.Left := ScaleX(80);
    RadioButton2.Top := RadioButton1.Top + ScaleY(60);
    RadioButton2.Width := Page.SurfaceWidth;
    RadioButton2.Height := ScaleY(17);
    RadioButton2.Caption := '自定义安装';
    RadioButton2.Checked := false;
    RadioButton2.Parent := Page.Surface;

    {设置label2的属性,并添加到页面中}
    Lbl2 := TNewStaticText.Create(Page);
    Lbl2.Left := ScaleX(95);
    Lbl2.Top := Lbl1.Top + ScaleY(60);
    Lbl2.Width := ScaleX(250);
    Lbl2.Height := ScaleY(50);
    Lbl2.Caption := '您可以选择单个安装项,建议经验丰富的用户使用';
    Lbl2.Parent := Page.Surface;
end;

   {调用系统自带的方法,InitializeWizard(),在此方法中调用我们定义的方法 CreateAddonPage --准确来说应该叫过程,而不叫方法}
procedure InitializeWizard();
begin
     CreateAddonPage;

end;

   {调用系统自带的 ShouldSkipPage方法,此方法是用来跳过某些向导页面的}
function ShouldSkipPage(PageID: Integer): Boolean;
begin

    {跳过 选择安装目录的页面 这里的 wpSelectDir,wpSelectProgramGroup都是Innosetup系统预设的,

    更多的页面id,请参考http://www.cnblogs.com/tommy-huang/p/4121229.html 中的第三点 }

    if (PageID = wpSelectDir) and (RadioButton1.Checked) then
         Result := True
    else if (PageID = wpSelectProgramGroup) and (RadioButton1.Checked) then
         Result := True
end;


原文地址:https://www.cnblogs.com/tommy-huang/p/4126496.html