这是我的解决方法:
像这样创建自定义类:
type
TFastThemedButton = class(TThemedMenuButton)
protected
procedure DrawBackground(var PaintRect: TRect); override;
end;
...
procedure TFastThemedButton.DrawBackground(var PaintRect: TRect);
const
MenuStates: array[Boolean {MouseInControl}, Boolean {Selected}] of TThemedMenu =
((tmMenuBarItemNormal, tmMenuBarItemPushed), (tmMenuBarItemHot, tmMenuBarItemPushed));
var
BannerRect: TRect;
StartCol, EndCol: TColor;
begin
Canvas.Brush.Color := ActionBar.ColorMap.Color;
Canvas.Font := ActionBar.Font;
StyleServices.DrawElement(Canvas.Handle, StyleServices.GetElementDetails(MenuStates[MouseInControl, (State=bsDown)]), PaintRect);
end;
现在在你的 TActionMainMenuBar.OnGetControlClass 添加这个简单的代码,并设置为 buggy actionclients tag=-100
procedure TfrmActions.ActionMainMenuBar1GetControlClass(Sender: TCustomActionBar; AnItem: TActionClient; var ControlClass: TCustomActionControlClass);
begin
if ControlClass.InheritsFrom(TCustomMenuButton) and then
begin
if (AnItem.Tag =-100) and (ControlClass = TThemedMenuButton) then
ControlClass := TFastThemedButton;
end;
end;
好吧,现在所有带有 -100 标签的根项目都可以按我们的意愿工作