Changing font of TActionMainMenuBar when using Vcl styles

偶尔善良 提交于 2019-12-04 11:17:09

As you say changing the font of the MenuItemTextNormal element (or any other) in the style designer has no effect, this is because the Vcl Style Engine simply ignores the font size and name, and just use the font color defined in the vcl style file.

As workaround you must define and register a new TActionBarStyleEx descendent and override the DrawText methods of the TCustomMenuItem and TCustomMenuButton classes, using the values of the Screen.MenuFont to draw the menu.

I just added a new unit (Vcl.PlatformVclStylesActnCtrls) to the Vcl Styles Utils project which implements a new Action Bar Style which allows to customize the font and size of the TActionMainMenuBar component.

To use it only add the Vcl.PlatformVclStylesActnCtrls unit to your project, change the values of the Screen.MenuFont font like

 Screen.MenuFont.Name := 'Impact';
 Screen.MenuFont.Size := 12;

and then set the Style of your TActionManager like so

  ActionManager1.Style:=PlatformVclStylesStyle;

And the result will be

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!