You can use the IsComponentSelected
function to check whether the component is selected or not. And for the validation might be good to use the NextButtonClick
event method, which allows you to stay on the page. In the following script is shown, how to display a confirmation message box if none of the components is selected and allows the user to stay on the page or continue:
[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;
Or the same shortened to less readable form:
[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;