如何访问在运行时的Delphi 2009功能区按钮的checked属性?
题
我想在任何功能区按钮,当点击了“确认”功能区的所有TAction对象的属性重置为false,那么只有把它放在按下的按钮如此。 但我并没有找到一种方法来访问ActionManager的行为的全部“选中”属性。 我想我需要遍历actionmanager的的ActionList ......但是,我却没有找到做正确的方式。 我会很高兴,如果有人可以给我一些这方面的暗示。
谢谢!
解决方案
TActionManager
从TCustomActionList
下降,因此你可以与后者做,你可以与前者做。它拥有你需要使用,Actions
,这是数组属性,让您可以访问列表中的所有操作,并ActionCount
,它告诉你有多少两个属性。用它们来写一个普通的循环,像这样的:
var
i: Integer;
Contained: TContainedAction;
Action: TCustomAction;
begin
for i := 0 to Pred(ActionList.ActionCount) do begin
Contained := ActionList[i]; // shorthand for ActionList.Actions[i]
if not (Contained is TCustomAction) then
continue; // Doesn't have Checked property
Action := TCustomAction(Contained);
Action.Checked := False;
end;
end;
动作列表可以容纳大量的各种各样的行动,他们并不都具有Checked
属性。该属性在TCustomAction
引入,所以上述的组合也代码过滤出不从该类下降的事。
不隶属于 StackOverflow