delphi - Inno Setup ComponentsList OnClick事件

标签 delphi inno-setup pascalscript

我有一个用于Inno Setup安装程序的组件列表,共有19个不同的选项,我想为其中一个组件设置OnClick事件。有没有办法做到这一点?还是有一种方法可以检查是否为所有组件都设置了触发OnClick事件的组件?

当前,OnClick事件设置如下:

Wizardform.ComponentsList.OnClick := @CheckChange;


我想做类似的事情:

Wizardform.ComponentsList.Items[x].OnClick := @DbCheckChange;


WizardForm.ComponentList声明为:TNewCheckListBox

最佳答案

您不想使用OnClick,请改用OnClickCheck

OnClick用于不更改选中状态的单击(例如,任何项目之外的单击;或对固定项目的单击;或使用键盘的选择更改),但是主要不使用键盘进行检查。

仅当检查状态更改时,键盘和鼠标均调用OnClickCheck

要确定用户检查了哪个项目,请使用ItemIndex属性。用户只能检查选定的项目。

虽然如果您具有组件层次结构或设置类型,但是由于子项/父项更改或安装类型更改而由安装程序自动检查的项目不会触发OnClickCheck(也不会触发OnClick) 。因此,要告知所有更改,您可以做的就是记住先前的状态,并在调用WizardForm.ComponentsList.OnClickCheckWizardForm.TypesCombo.OnChange时将其与当前状态进行比较。

const
  TheItem = 2; { the item you are interested in }

var
  PrevItemChecked: Boolean;
  TypesComboOnChangePrev: TNotifyEvent;

procedure ComponentsListCheckChanges;
var
  Item: string;
begin
  if PrevItemChecked <> WizardForm.ComponentsList.Checked[TheItem] then
  begin
    Item := WizardForm.ComponentsList.ItemCaption[TheItem];
    if WizardForm.ComponentsList.Checked[TheItem] then
    begin
      Log(Format('"%s" checked', [Item]));
    end
      else
    begin
      Log(Format('"%s" unchecked', [Item]));
    end;

    PrevItemChecked := WizardForm.ComponentsList.Checked[TheItem];
  end;
end;

procedure ComponentsListClickCheck(Sender: TObject);
begin
  ComponentsListCheckChanges;
end;

procedure TypesComboOnChange(Sender: TObject);
begin
  { First let Inno Setup update the components selection }
  TypesComboOnChangePrev(Sender);
  { And then check for changes }
  ComponentsListCheckChanges;
end;

procedure InitializeWizard();
begin
  WizardForm.ComponentsList.OnClickCheck := @ComponentsListClickCheck;

  { The Inno Setup itself relies on the WizardForm.TypesCombo.OnChange, }
  { so we have to preserve its handler. }
  TypesComboOnChangePrev := WizardForm.TypesCombo.OnChange;
  WizardForm.TypesCombo.OnChange := @TypesComboOnChange;

  { Remember the initial state }
  { (by now the components are already selected according to }
  { the defaults or the previous installation) }
  PrevItemChecked := WizardForm.ComponentsList.Checked[TheItem];
end;




有关更通用的解决方案,请参见Inno Setup Detect changed task/item in TasksList.OnClickCheck event。尽管有组件,但也必须触发WizardForm.TypesCombo.OnChange调用的检查。

关于delphi - Inno Setup ComponentsList OnClick事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36989349/

相关文章:

delphi - 检测到系统中的 BIOS 数据 (Delphi)

delphi - 如何删除最后一个字符

delphi - 为什么 TIdTextEncoding.Default 未声明?

java - 包装和使用安装程序后可执行文件不会在 Windows 上退出

windows - Inno Setup 始终在 Pascal Script 代码中以 32 位模式启动 PowerShell

inno-setup - 根据 Inno Setup 中编辑框的更改更新控件

inno-setup - Inno Setup 获取目录大小(包括子目录)

inno-setup - 创新设置 : Working with JSON

android - 如何根据 FireMonkey 移动应用程序中的设备动态更改背景图像文件?

C# DLL 导出到 Inno-Setup - 错误 E0434F4D