我正在编写一个包含以下部分的InnoSetup安装程序:
[Types]
Name: "ChooseVers"; Description: "Install support for WordPerfect versions:"; Flags: iscustom
[Components]
Name: "InstallForWP51"; Description: "Install support for WordPerfect 5.1"; Types: ChooseVers; Flags: checkablealone
Name: "InstallForWP62"; Description: "Install support for WordPerfect 6.2"; Types: ChooseVers; Flags: checkablealone当用户运行安装程序时,它会为组件下面列出的两个项提供两个复选框,用户可以检查其中的一个,也可以同时选中两个。
我要做的是,如果用户不选中任何一个框,则显示一条消息,这样就不会安装任何东西。目前,用户只看到一条有点误导的消息,在将要执行的操作列表中没有列出任何内容,然后安装程序就会关闭。这没有什么严重的问题,但最好是提供更多的信息。
我将非常感谢在这方面的任何帮助。
发布于 2014-04-27 14:02:47
您可以使用IsComponentSelected函数来检查组件是否被选中。对于验证,最好使用NextButtonClick事件方法,它允许您停留在页面上。在下面的脚本中,如果没有选择任何组件并允许用户停留在页面上或继续,如何显示确认消息框:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Types]
Name: "ChooseVers"; Description: "Install support for WordPerfect versions:"; Flags: iscustom
[Components]
Name: "InstallForWP51"; Description: "Install support for WordPerfect 5.1"; Types: ChooseVers; Flags: checkablealone
Name: "InstallForWP62"; Description: "Install support for WordPerfect 6.2"; Types: ChooseVers; Flags: checkablealone
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if (CurPageID = wpSelectComponents) and not (IsComponentSelected('InstallForWP51') or
IsComponentSelected('InstallForWP62')) then
begin
Result := MsgBox('None of the components is selected. This won''t install ' +
'anything. Are you sure you want to continue ?', mbConfirmation, MB_YESNO) = IDYES;
end;
end;或缩短为较难读的形式:
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := (CurPageID <> wpSelectComponents) or (IsComponentSelected('InstallForWP51') or
IsComponentSelected('InstallForWP62')) or (MsgBox('None of the components is selected. ' +
'This won''t install anything. Are you sure you want to continue ?', mbConfirmation,
MB_YESNO) = IDYES);
end;https://stackoverflow.com/questions/23323330
复制相似问题