delphi – Inno Setup ComponentsList OnClick事件

我有一个Inno Setup安装程序的组件列表,19个不同的选项,我想为其中一个组件设置OnClick事件.有没有办法做到这一点?或者有没有办法检查哪个组件触发了OnClick事件,如果它是为所有组件设置的?

目前,OnClick事件设置如下:

Wizardform.ComponentsList.OnClick := @CheckChange;

我想做的事情如下:

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

WizardForm.ComponentList声明为:TNewCheckListBox

解决方法

您不想使用OnClick,而是使用OnClickChange.

OnClick被调用用于不改变已检查状态的点击(例如任何项目之外的点击;或点击固定项目;或使用键盘进行选择更改),但主要是不使用键盘进行检查.

仅当选中状态更改时,才会调用OnClickChange,键盘和鼠标都会调用OnClickChange.

要告诉用户检查了哪个项目,请使用ItemIndex属性.用户只能检查所选项目.

虽然如果您有组件层次结构或安装类型,但由于子/父项目的更改或安装类型的更改,安装程序自动检查的项目将不会触发OnClickCheck(也不会触发OnClick).因此,要告诉所有更改,您可以做的就是记住先前的状态,并在调用WizardForm.ComponentsList.OnClickCheck或WizardForm.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 API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...