在先前的问题中,我询问了如何使用三个可选组件,其中用户还可以单独指定每个组件的位置(例如,代码部分和两个HTML Web应用程序).@Miral给了我一个很好的答案,我现在已经实现了:
三个用户定义位置的三个组件
我还有一个小小的审美问题.我总是CreateInputDirPage在向导中创建并询问用户.问题出现在wpSelectComponents.
问题:如果未选择组件,如何跳过页面.也就是说,如何跳过我的自定义页面?
我有一种与它有关的感觉ShouldSkipPage().但我不知道PageID我的自定义页面是什么,以及如何测试以查看选择了哪些组件.
function ShouldSkipPage(PageID:Integer):Boolean;
向导调用此事件函数来确定是否应显示特定页面(由PageID指定).如果您返回True,将跳过该页面; 如果您返回False,则可能会显示该页面.
我的脚本如下:
[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;
Run Code Online (Sandbox Code Playgroud)
TLa*_*ama 28
正如您所正确的那样,您需要使用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;
Run Code Online (Sandbox Code Playgroud)
我对此的看法是使用TWizardPageShouldSkipEvent,我只做了一个案例和点脚本:
[Code]
var
TobyDirPage: TInputDirWizardPage;
function SkipEvent (Sender: TWizardPage): Boolean;
begin
Result := not IsComponentSelected('Toby');
end;
procedure InitializeWizard;
begin
TobyDirPage := CreateInputDirPage(wpSelectComponents, yadda yadda yadda
TobyDirPage.OnShouldSkipPage := @SkipEvent;
end;
Run Code Online (Sandbox Code Playgroud)
现在,OnShouldSkipPage在按下Next wpSelectComponents之前和之后立即触发TobyDirPage绘制,因为您可以将该事件附加到页面本身,所以您不需要使用PageID's.
| 归档时间: |
|
| 查看次数: |
10425 次 |
| 最近记录: |