InnoSetup, prevent installation if any task is selected

左心房为你撑大大i 提交于 2019-12-04 16:50:14

There is no way to do what you want natively in Inno Setup. You will need to do it from code by yourself.

You can cheat here a bit by using the WizardSelectedTasks function. This function returns a comma separated list of selected task names (or descriptions), and so it returns an empty string when no task is selected. The rest is about binding task list OnClickCheck event, and updating the next button enable state and writing a piece of code to initialize the next button state:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Tasks]
Name: client; Description: Install FTP client
Name: server; Description: Install FTP server

[Code]
// helper function
function IsAnyTaskSelected: Boolean;
begin
  Result := WizardSelectedTasks(False) <> '';
end;

// event handler for setting the next button initial state when
// entering the tasks page
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
    WizardForm.NextButton.Enabled := IsAnyTaskSelected;
end;

// method of the task list check click event
procedure TasksListClickCheck(Sender: TObject);
begin
  WizardForm.NextButton.Enabled := IsAnyTaskSelected;
end;

procedure InitializeWizard;
begin
  WizardForm.TasksList.OnClickCheck := @TasksListClickCheck;
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!