首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Custom Draw TAction下拉菜单

Custom Draw TAction下拉菜单
EN

Stack Overflow用户
提问于 2012-02-24 11:30:09
回答 1查看 329关注 0票数 2

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

代码语言:javascript
复制
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;

干杯。

EN

回答 1

Stack Overflow用户

发布于 2012-02-24 15:42:55

自定义绘图事件处理程序始终附着到UI组件,而不是动作。所以使用普通的VCL你不能做你所要求的事情。

派生添加了OnDraw事件的您自己的操作类将非常简单。您还必须派生自己的dropdown menu类来提供连接的另一端。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9424983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档