【问题标题】:How to skip custom page based on setup type in Inno Setup如何根据 Inno Setup 中的设置类型跳过自定义页面
【发布时间】:2020-05-26 16:39:52
【问题描述】:

我正在使用服务器和客户端安装/设置类型构建我的设置。 如果用户选择服务器类型,我需要跳过或隐藏自定义页面。 服务器类型只有一个自定义页面选择SQL实例和一个启动按钮sqlcmd安装DB,而客户端安装只复制一些文件到程序目录。

这是我的自定义页面测试代码:

[Types]
Name: "Server"; Description: "Server"
Name: "Client"; Description: "Client"

[Components]
Name: "Dictation"; Description: "Dictation"; Types: Client
Name: "DigitalSign"; Description: "Digital Sign"; Types: Client

[Tasks]
Name: "Voisis"; Description: "Voisis"; Components: Dictation
Name: "Recomed"; Description: "Recomed"; Components: Dictation

[Code]

var
   Page: TWizardPage;
   Panel: TPanel;
   Edit0,Edit1,Edit2,Edit3: TNewEdit;
   StaticText0, StaticText1,StaticText2,StaticText3: TNewStaticText;

procedure InitializeWizard;
begin
    { Create the pages }

    Page := CreateCustomPage (wpInfoBefore, 'Personal Information', 'Who are you?');

    Edit0 := TNewEdit.Create(Page);
    Edit0.Top := ScaleY(16);
    Edit0.Width := Page.SurfaceWidth div 3 - ScaleX(8);
    Edit0.Text := 'localhost\WISE';
    Edit0.Parent := Page.Surface;

    Edit1 := TNewEdit.Create(Page);
    Edit1.Top := ScaleY(64);
    Edit1.Width := Page.SurfaceWidth div 3 - ScaleX(8);
    Edit1.Text := 'sa';
    Edit1.Parent := Page.Surface;

    Edit2 := TNewEdit.Create(Page);
    Edit2.Top := ScaleY(112);
    Edit2.Width := Page.SurfaceWidth div 3 - ScaleX(8);
    Edit2.Text := 'Password';
    Edit2.Parent := Page.Surface;

    Edit3 := TNewEdit.Create(Page);
    Edit3.Top := ScaleY(160);
    Edit3.Width := Page.SurfaceWidth div 3 - ScaleX(8);
    Edit3.Text := 'TNewEdit';
    Edit3.Parent := Page.Surface;


    StaticText0 := TNewStaticText.Create(Page);
    Statictext0.Top := ScaleY(2);
    StaticText0.Caption := 'Istanza';
    StaticText0.AutoSize := True;
    StaticText0.Parent := Page.Surface;

    StaticText1 := TNewStaticText.Create(Page);
    Statictext1.Top := ScaleY(50);
    StaticText1.Caption := 'User';
    StaticText1.AutoSize := True;
    StaticText1.Parent := Page.Surface;


    StaticText2 := TNewStaticText.Create(Page);
    Statictext2.Top := ScaleY(98);
    StaticText2.Caption := 'Password';
    StaticText2.AutoSize := True;
    StaticText2.Parent := Page.Surface;


    StaticText3 := TNewStaticText.Create(Page);
    Statictext3.Top := ScaleY(146);
    StaticText3.Caption := 'bho';
    StaticText3.AutoSize := True;
    StaticText3.Parent := Page.Surface;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
    Result := False;

    if PageID = PageID then
        Result := not IsComponentSelected('Server');
end;

【问题讨论】:

    标签: inno-setup pascalscript


    【解决方案1】:

    ShouldSkipPage 事件函数中,将PageID 与自定义页面的TWizardPage.ID 进行比较。并使用WizardSetupType support function 测试选择的设置类型。

    var
      Page: TWizardPage;
    
    function ShouldSkipPage(PageID: Integer): Boolean;
    begin
      Result := False;
    
      if Page.ID = PageID then
        Result := (WizardSetupType(False) <> 'server');
    end;
    

    显然,您的自定义页面必须显示在之后 “选择组件”页面,而不是之前:

    Page := CreateCustomPage(wpSelectComponents, ...);
    

    或者,您可以处理自定义页面的TWizardPage.OnShouldSkipPage

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-04
      • 1970-01-01
      • 2016-02-06
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多