gpt4 book ai didi

checkbox - 如何在InnoSetup向导页面中读取和设置复选框的值?

转载 作者:行者123 更新时间:2023-12-02 11:22:31 25 4
gpt4 key购买 nike

我在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;

关于checkbox - 如何在InnoSetup向导页面中读取和设置复选框的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10490046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com