How to read and set the flag value on the InnoSetup wizard page?

I added a checkbox on the Advanced Tasks page of the InnoSetup script with

[Tasks] Name: "StartMenuEntry" ; Description: "Start my app when Windows starts" ; GroupDescription: "Windows Startup"; MinVersion: 4,4; 

I want to initialize this flag when the wpSelectTasks page is wpSelectTasks , and read the value when clicking Next . I cannot figure out how to access the checked checkbox.

 function NextButtonClick(CurPageID: Integer): Boolean; var SelectTasksPage : TWizardPage ; StartupCheckbox : TCheckbox ; begin Result := true ; case CurPageID of wpSelectTasks : begin SelectTasksPage := PageFromID (wpSelectTasks) ; StartupCheckbox := TCheckbox (SelectTasksPage... { <== what goes here??? } StartupCheckboxState := StartupCheckbox.Checked ; end ; end ; end ; 
+8
checkbox inno-setup pascalscript
source share
2 answers

Task flags are actually items in the WizardForm.TasksList checklist. If you know their indexes, you can easily access them. Please note that the elements can be grouped (just your case), and each new group also takes one element in this list, so for your case the index of the element will be 1:

 [Setup] AppName=TasksList AppVersion=1.0 DefaultDirName={pf}\TasksList [Tasks] Name: "TaskEntry"; Description: "Description"; GroupDescription: "Group"; [code] function NextButtonClick(CurPageID: Integer): Boolean; begin Result := True; if CurPageID = wpSelectTasks then begin if WizardForm.TasksList.Checked[1] then MsgBox('First task has been checked.', mbInformation, MB_OK) else MsgBox('First task has NOT been checked.', mbInformation, MB_OK); end; end; procedure CurPageChanged(CurPageID: Integer); begin if CurPageID = wpSelectTasks then WizardForm.TasksList.Checked[1] := False; end; 

This is how the WizardForm.TasksList validation WizardForm.TasksList will look when you have two tasks with different groups:

enter image description here

To access the task, according to its description, try the following:

 [Setup] AppName=Task List AppVersion=1.0 DefaultDirName={pf}\TasksList [Tasks] Name: "Task"; Description: "Task Description"; GroupDescription: "Group 1"; [code] function NextButtonClick(CurPageID: Integer): Boolean; var Index: Integer; begin Result := True; if CurPageID = wpSelectTasks then begin Index := WizardForm.TasksList.Items.IndexOf('Task Description'); if Index <> -1 then begin if WizardForm.TasksList.Checked[Index] then MsgBox('First task has been checked.', mbInformation, MB_OK) else MsgBox('First task has NOT been checked.', mbInformation, MB_OK); end; end; end; procedure CurPageChanged(CurPageID: Integer); var Index: Integer; begin if CurPageID = wpSelectTasks then begin Index := WizardForm.TasksList.Items.IndexOf('Task Description'); if Index <> -1 then WizardForm.TasksList.Checked[Index] := False; end; end; 
+16
source share

Great answer above. Give me only what I need.

I had a case where I had many additional installers in which I used the checkonce parameter, but I wanted them to be re-checked if the folder was missing (for example, the user deleted the installation folder manually), for example

 [Tasks] Name: "InstallPython" ; Description: "Install Python" ; Flags: checkedonce Name: "InstallNPP" ; Description: "Install Notepad++" ; Flags: checkedonce [Code] procedure CurPageChanged(CurPageID: Integer); var ItemIx: Integer; begin if CurPageID = wpSelectTasks then begin if not DirExists(ExpandConstant('{app}')) then begin for ItemIx := 0 to (WizardForm.TasksList.Items.Count - 1) do WizardForm.TasksList.Checked[ItemIx] := True; end end end; 
0
source share

All Articles