gpt4 book ai didi

inno-setup - 在 Inno Setup 中跳过基于可选组件的自定义页面

转载 作者:行者123 更新时间:2023-12-02 22:45:06 24 4
gpt4 key购买 nike

在上一个问题中,我询问如何拥有三个可选组件,用户还可以分别指定每个组件的位置(例如,一个代码部分和两个 HTML Web 应用程序)。 @Miral 给了我一个很好的答案,我现在已经实现了:
three components in three user defined locations

我还有一个小小的审美问题。我总是在向导中创建并向用户询问 CreateInputDirPage。问题出现在 wpSelectComponents 之后。

问题:如果没有选择组件,如何跳过该页面。也就是说,如何跳过我的自定义页面?

我有一种感觉,它与 ShouldSkipPage() 有关。但我不知道自定义页面的 PageID 是什么,也不知道如何测试以查看选择了哪些组件。

function ShouldSkipPage(PageID: Integer): Boolean;

The wizard calls this event function to determine whether or not a particular page (specified by PageID) should be shown at all. If you return True, the page will be skipped; if you return False, the page may be shown.

我的脚本附在下面:

[Components]
Name: "Watson"; Description: "Watson Component"; Types: onlywatson full
Name: "Toby"; Description: "Toby Component"; Types: onlytoby full
Name: "Sherlock"; Description: "Sherlock Component"; Types: onlysherlock full

[Code]
var
TobyDirPage: TInputDirWizardPage;
SherlockDirPage: TInputDirWizardPage;

procedure InitializeWizard;
begin
TobyDirPage := CreateInputDirPage(wpSelectComponents,
'Select Location for Toby Web Pages', 'Where should we store the sample Toby application files?',
'The sample Toby stand-alone map application will be saved in the following folder.'#13#10#13#10 +
'To continue, click Next. If you would like to select a different folder, click Browse.',
False, 'New Folder');
{ Add item (with an empty caption) }
TobyDirPage.Add('');
{ Set initial value (optional) }
TobyDirPage.Values[0] := ExpandConstant('c:\wwwroot\Toby');

SherlockDirPage := CreateInputDirPage(wpSelectComponents,
'Select Location for Sherlock Web Pages', 'Where should we store the Sherlock Catalog Search Tool?',
'Sherlock.html and it'#39 + 's associated files will be saved in the following folder.'#13#10#13#10 +
'To continue, click Next. If you would like to select a different folder, click Browse.',
False, 'New Folder');
{ Add item (with an empty caption) }
SherlockDirPage.Add('');
{ Set initial value (optional) }
SherlockDirPage.Values[0] := ExpandConstant('c:\wwwroot\Sherlock');
end;

function GetTobyDir(Param: String): String;
begin
{ Return the selected TobyDir }
Result := TobyDirPage.Values[0];
end;

function GetSherlockDir(Param: String): String;
begin
{ Return the selected TobyDir }
Result := SherlockDirPage.Values[0];
end;

最佳答案

正如您正确预见的那样,您需要使用ShouldSkipPage有条件地跳过页面的事件处理程序。要检查是否选择了某个组件,请使用 IsComponentSelected函数,最后,要获取自定义页面的 ID,您需要存储其 ID 。将所有内容放在一起可能会得到以下示例脚本:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Components]
Name: "help"; Description: "Help File";

[Code]
var
CustomPageID: Integer;

procedure InitializeWizard;
var
CustomPage: TInputDirWizardPage;
begin
CustomPage := CreateInputDirPage(wpSelectComponents, 'Caption',
'Description', 'SubCaption', False, 'NewFolderName');
CustomPage.Add('Input');
{ store your custom page ID to further use in the ShouldSkipPage event }
CustomPageID := CustomPage.ID;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
{ initialize result to not skip any page (not necessary, but safer) }
Result := False;
{ if the page that is asked to be skipped is your custom page, then... }
if PageID = CustomPageID then
{ if the component is not selected, skip the page }
Result := not IsComponentSelected('help');
end;

关于inno-setup - 在 Inno Setup 中跳过基于可选组件的自定义页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13921535/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com