【问题标题】:Custom Draw TAction Dropdown menu自定义绘制 TAction 下拉菜单
【发布时间】:2012-03-14 13:30:21
【问题描述】:

我为带有 TAction 列表的 TActionClientItem 创建了一个下拉菜单。我想知道如何挂钩菜单的绘图事件或内部的每个 TAction 以不同的方式显示这些 TAction 的标题!? 像 TAction.OnDrawItem 或 TActionClientItem .OnDrawItem ...

procedure xxxxx.BuildActionMenu;
var
  iLoop : Integer;
  oItem : TAction;
  oClientItem : TActionClientItem;
begin
  if Assigned(oClientItem) then
    for iLoop := oClientItem.Items.Count - 1 downto 0 do
      oClientItem.Items.Delete(iLoop);

  for iLoop := 0 to List.Count - 1 do
  begin
    oItem := TAction.Create(actionList);
    oItem.Caption := List[iLoop].Name;
    oItem.Tag := iLoop;
    oItem.OnExecute := HandleOnExecuteMenuItem;
    **oItem.OnDraw = WhateverFunction**
    oClientItem .Items.Add.Action := oItem;
  end;

  if Assigned(oClientItem) then
  begin
    if oClientItem.CommandProperties is TButtonProperties then
      TButtonProperties(oClientItem.CommandProperties).ButtonType := btSplit;
    TAction(oClientItem.Action).OnExecute := HandleOnExecuteParentItem;
    **oClientItem.OnDraw = WhateverFunction**        
  end;
end;

干杯。

【问题讨论】:

    标签: delphi delphi-xe taction


    【解决方案1】:

    自定义绘图事件处理程序始终附加到 UI 组件而不是操作。所以对于普通的 VCL,你不能做你所要求的。

    派生您自己的添加 OnDraw 事件的动作类就足够简单了。您还必须派生自己的下拉菜单类来提供连接的另一端。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 2012-10-12
      • 1970-01-01
      • 2021-08-22
      • 2018-11-30
      • 2011-02-06
      相关资源
      最近更新 更多