如何在运行时访问 Delphi 2009 功能区按钮的选中属性?

发布于 2024-07-25 23:57:42 字数 220 浏览 1 评论 0原文

我想在单击任何功能区按钮时将功能区的所有 TAction 对象的“checked”属性重置为 false,然后仅在按下的按钮上将其设置为 true。 但我还没有找到一种方法来访问 ActionManager 的 Actions 的所有“checked”属性。 我想我需要循环遍历动作管理器的动作列表......但是,但我还没有找到正确的方法。 如果有人能给我一些提示,我会很高兴。

谢谢!

I want to reset the "checked" property of all TAction objects of a ribbon to false when clicking on any ribbon button and then only set it true on the pressed button.
But I did not yet find a way to access all the "checked" properties of the ActionManager's Actions.
I think I need to loop through the actionmanager's actionlist... however, but I did not yet find the right way to do.
I'd be very glad if someone could give me some hint on this.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笔落惊风雨 2024-08-01 23:57:42

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 中引入的,因此上面的代码也过滤掉了不属于该类的内容。

TActionManager descends from TCustomActionList, so whatever you can do with the latter, you can do with the former. It has two properties you'll need to use, Actions, which is the array property that gives you access to all the list's actions, and ActionCount, which tells you how many there are. Use them to write an ordinary loop, like this:

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;

Action lists can hold lots of kinds of actions, and they don't all have Checked properties. That property is introduced in TCustomAction, so the code above also filters out the things that don't descend from that class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文