Inno Setup函数CheckItem语法和用法

时间:2015-06-24 21:57:45

标签: inno-setup

继我的问题Inno Setup disable component selection when a specific component is selected之后,我认为可能有办法让这个工作没有问题,在代码中设置的检查状态是永久性的(尽管使用Checked属性)改为使用:

function CheckItem(const Index: Integer; const AOperation: TCheckItemOperation): Boolean;
TNewCheckListBox中的

,但是我无法正确获取语法。我在尝试:

CheckItem(CompIndexSync, coUncheck) := Checked[CompIndexClient];

其中CompIndexes是分配给组件值索引的常量。我在编译时遇到标识符预期错误。有人可以建议如何正确使用这个功能以及我做错了什么?

1 个答案:

答案 0 :(得分:1)

CheckItem类的TNewCheckListBox成员是类型函数的方法,它通过AOperation操作更新已检查状态,如果对状态有任何更改,则返回True。 Index或其任何子女的项目。这是它的原型(source):

function TNewCheckListBox.CheckItem(const Index: Integer;
  const AOperation: TCheckItemOperation): Boolean;

问题在于您尝试为函数结果赋值。这不是一般用Pascal语言做的。 您想要对项目执行的操作由AOperation参数传递。在伪代码中例如:

var
  CheckList: TNewCheckListBox;
  Operation: TCheckItemOperation;
begin
  ...
  if ShouldCheck then
    Operation := coCheck
  else
    Operation := coUncheck;

  if CheckList.CheckItem(ItemIndex, Operation) then
    MsgBox('An item has changed its state.', mbInformation, MB_OK);
end;