如何读取和设置InnoSetup向导页面中的复选框的值? [英] How do read and set the value of a checkbox in an InnoSetup wizard page?

查看:2714
本文介绍了如何读取和设置InnoSetup向导页面中的复选框的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在InnoSetup脚本的其他任务页面添加了一个复选框。

I have added a checkbox to the "Additional Tasks" page of an InnoSetup script with

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

我想在 wpSelectTasks 页面显示,并在单击下一步按钮时读取该值。我不能解决如何访问复选框`checked'的值。

I want to initialize this checkbox when the wpSelectTasks page shows, and read the value when the Next button is clicked. I can't work out how to access the checkbox `checked' value.

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:

The task check boxes are in fact items in the WizardForm.TasksList check list box. If you know their indexes you can access them pretty easily. Note, that the items can be grouped (what is just your case) and each new group takes also one item in that check list box, so for your case the item index 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;

这里说明了 WizardForm.TasksList 检查列表框看起来像当你有两个任务, :

Here is illustrated how the WizardForm.TasksList check list box would looks like when you'd have two tasks with different groups:

>

要通过其描述访问任务复选框,请尝试以下操作:

To access the task check box by 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;   

这篇关于如何读取和设置InnoSetup向导页面中的复选框的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆