我为一个带有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;干杯。
发布于 2012-02-24 15:42:55
自定义绘图事件处理程序始终附着到UI组件,而不是动作。所以使用普通的VCL你不能做你所要求的事情。
派生添加了OnDraw事件的您自己的操作类将非常简单。您还必须派生自己的dropdown menu类来提供连接的另一端。
https://stackoverflow.com/questions/9424983
复制相似问题