Inno Setup ComponentsList OnClick事件 [英] Inno Setup ComponentsList OnClick event
问题描述
OnClick
事件,如果它为所有组件设置? 目前, OnClick
事件设置如下:
Wizardform.ComponentsList.OnClick := @CheckChange;
我想做一些像:
Wizardform.ComponentsList.Items [x] .OnClick:= @DbCheckChange;
将$ code WizardForm.ComponentList 声明为: TNewCheckListBox
您不想使用 OnClick
,使用 OnClickChange
。
对于不更改检查状态的点击(例如任何项目之外的点击;或固定项目的点击;或使用键盘进行的选择更改),点击
被调用,但主要是不使用键盘进行检查。 / p>
OnClickChange
仅在被检查状态改变时被调用,而对于键盘和鼠标都是调用的。
要告诉用户检查哪个项目,请使用 ItemIndex
属性。用户只能检查所选项目。
尽管如果您有组件层次结构或设置类型,由于安装程序由于子/父项或设置类型的更改不会触发 OnClickCheck
(也不是 OnClick
)。所以要告诉所有的更改,你可以做的就是记住以前的状态,并将它与当前状态进行比较,当 WizardForm.ComponentsList.OnClickCheck
或 WizardForm.TypesCombo.OnChange
被调用。
const
TheItem = 2; {你感兴趣的项目}
var
PrevItemChecked:Boolean;
TypesComboOnChangePrev:TNotifyEvent;
procedure ComponentsListCheckChanges;
var
Item:string;
begin
如果PrevItemChecked<> WizardForm.ComponentsList.Checked [TheItem]然后
begin
Item:= WizardForm.ComponentsList.ItemCaption [TheItem];
如果WizardForm.ComponentsList.Checked [TheItem]然后
开始
日志(格式('%schecked,[Item]));
end
else
begin
日志(格式(''%sunchecked',[Item]));
结束
PrevItemChecked:= WizardForm.ComponentsList.Checked [TheItem];
结束
结束
procedure ComponentsListClickCheck(Sender:TObject);
begin
ComponentsListCheckChanges;
结束
procedure TypesComboOnChange(Sender:TObject);
begin
{首先让Inno Setup更新组件选择}
TypesComboOnChangePrev(Sender);
{然后检查更改}
ComponentsListCheckChanges;
结束
procedure InitializeWizard();
begin
WizardForm.ComponentsList.OnClickCheck:= @ComponentsListClickCheck;
{Inno Setup本身依赖于WizardForm.TypesCombo.OnChange,}
{所以我们必须保留其处理程序。 }
TypesComboOnChangePrev:= WizardForm.TypesCombo.OnChange;
WizardForm.TypesCombo.OnChange:= @TypesComboOnChange;
{记住初始状态}
{(现在组件已经根据}
{默认或以前的安装)}
PrevItemChecked = WizardForm.ComponentsList.Checked [TheItem];
结束
有关更通用的解决方案,请参阅 Inno安装程序检测TasksList.OnClickCheck事件中更改的任务/项目。虽然使用组件,但是必须触发对 WizardForm.TypesCombo.OnChange
调用的检查。
I have a list of components for my Inno Setup installer, 19 different options, I want to set the OnClick
event for ONE of the components. Is there a way to do this? Or is there a way to check which component triggered the OnClick
event if it's set for all components?
Currently, the OnClick
event is set like so:
Wizardform.ComponentsList.OnClick := @CheckChange;
I would like to do something like:
Wizardform.ComponentsList.Items[x].OnClick := @DbCheckChange;
The WizardForm.ComponentList
is declared as a: TNewCheckListBox
You do not want to use OnClick
, use OnClickChange
instead.
The OnClick
is called for clicks which not change checked state (like clicks outside of any item; or clicks on fixed items; or selection change using keyboard), but mainly it is not called for checks using keyboard.
The OnClickChange
is called only, when the checked state changes, and both for keyboard and mouse.
To tell which item was checked by user, use ItemIndex
property. The user can check only the selected item.
Though if you have a components hierarchy, or setup types, the items checked automatically by the installer due to a change in child/parent items or change in the setup type, won't trigger the OnClickCheck
(nor the OnClick
). So to tell all changes, all you can do is to remember the previous state and compare it against the current state, when the WizardForm.ComponentsList.OnClickCheck
or WizardForm.TypesCombo.OnChange
are called.
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;
For a more generic solution, see Inno Setup Detect changed task/item in TasksList.OnClickCheck event. Though with components, one has to trigger the check on the WizardForm.TypesCombo.OnChange
call too.
这篇关于Inno Setup ComponentsList OnClick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!