Inno Setup:选择组件的功能 [英] Inno Setup: Function to select a component

查看:347
本文介绍了Inno Setup:选择组件的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题.选择一个或两个组件时,我需要显示一个页面.但是另一个不能仅使用单个组件就好像有效果.我留下了我正在使用的代码.

I have a small problem. I need that a page is displayed when you select one or two components. But the other is not work only with a single component seems to have an effect. I leave the code that I'm working.

[Setup]
AppName=My Program
AppVerName=My Program v.1.2
DefaultDirName={pf}\My Program

[Types]
Name: full; Description: Full installation
Name: compact; Description: Compact installation
Name: custom; Description: Custom installation; Flags: iscustom

[Components]
Name: program; Description: Program Files; Types: full compact custom; Flags: fixed
Name: help; Description: Help File; Types: full
Name: readme; Description: Readme File; Types: full
Name: readme\en; Description: English; Flags: exclusive
Name: readme\de; Description: German; Flags: exclusive

[Code]
var
  Page1: TWizardPage;

Procedure InitializeWizard();
begin
  Page1:= CreateCustomPage(wpSelectComponents, 'Custom wizard page 1', 'TButton');
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Case PageID of
    Page1.ID: Result:= not IsComponentSelected('help');
    Page1.ID: Result:= not IsComponentSelected('readme\de'); //  It does not work
  end;
end;

预先致以问候和感谢.

推荐答案

如果您需要编写更复杂的条件,请使用逻辑运算符.在这种情况下,您想使用and运算符:

If you need to write more complex conditions, use logical operators for that. In this case you wanted to use the and operator:

Result := not IsComponentSelected('help') and not IsComponentSelected('readme\de');

可以读为:

如果未选择帮助"组件并且单击自述文件\ de",则跳过页面 组件也未选中.用人类语言可能会跳过 如果未选择帮助"或"readme \ de"组件,则显示该页面.

Skip page if "help" component is not selected and "readme\de" component is not selected as well. In human language it could be, skip page if neither "help" nor "readme\de" component is selected.

您的代码可以简化为:

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // skip the page if it's our custom page and neither "help" nor "readme\de"
  // component is selected, do not skip otherwise
  Result := (PageID = Page1.ID) and (not IsComponentSelected('help') and
    not IsComponentSelected('readme\de'));
end;

最后一个注意事项(以及可能的问题原因),请注意在case语句中打开相同的标识符.编译器不应允许您这样做,但不幸的是,例如编译:

One final note (and a possible cause of problems), beware of switching on the same identifier in case statements. Compiler should not allow you doing this but unfortunately does, e.g. this compiles:

var
  I: Integer;
begin
  I := 1;
  case I of
    1: MsgBox('Case switch 1.1', mbInformation, MB_OK);
    1: MsgBox('Case switch 1.2', mbInformation, MB_OK);
  end;
end;

但是只有第一个switch值语句执行,所以您将永远不会看到消息"Case switch 1.2" .

But only the first switch value statement executes, so you'll never see the message "Case switch 1.2".

这篇关于Inno Setup:选择组件的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆