2

我为带有 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;

干杯。

4

1 回答 1

0

自定义绘图事件处理程序始终附加到 UI 组件而不是操作。因此,使用普通的 VCL,您无法按照您的要求进行操作。

派生您自己的添加 OnDraw 事件的操作类会很简单。您还必须派生自己的下拉菜单类来提供连接的另一端。

于 2012-02-24T07:42:54.747 回答