如何在Inno setup中根据设置类型跳过自定义页面



我正在使用服务器和客户端安装/设置类型构建我的设置。如果用户选择服务器类型,我需要跳过或隐藏自定义页面。服务器类型只有一个选择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 := 'localhostWISE';
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;

ShouldSkipPage事件函数中,将PageID与自定义页面的TWizardPage.ID进行比较。并使用WizardSetupType支持功能来测试所选的设置类型。

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

例如,请参阅Skip Inno Setup自定义页面,除非在上一页上选择了特定的单选按钮。

相关内容

  • 没有找到相关文章

最新更新