我添加了一个复选框以“附加任务”页面的InnoSetup脚本
[Tasks]
Name: "StartMenuEntry" ; Description: "Start my app when Windows starts" ; GroupDescription: "Windows Startup"; MinVersion: 4,4;
我想初始化这个复选框时wpSelectTasks
页显示,和当读出的值Next
按钮被点击。 我不能工作了如何访问复选框选中'”值。
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 ;
任务复选框在实际上项目WizardForm.TasksList
检查列表框中。 如果你知道自己的索引,你可以很容易地访问它们。 请注意,该项目可以进行分组(什么是公正的情况下),并且每个新组也需要一个项目,登记入住的列表框中,所以你的情况下,项目指标将是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;
下面是说明如何WizardForm.TasksList
检查列表框将看起来像当你有不同的组中的两个任务:
被其描述访问任务复选框,请尝试以下操作:
[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;
上面伟大的答案。 给我我需要的。
我有,我有一堆我用了“checkonce”选项二次安装的情况,但我想他们重新检查,如果该文件夹不见了(例如,用户在安装文件夹手动消灭),例如
[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;