Forum > Win32/64

Menu Colors

(1/2) > >>

I need to set the background and text color of menu items. But don't seem to be able to do so.

This is specifically needed for Windows where the various colors are not inherited from the OS theme. On Linux, if I have a dark theme, all components recognise that and follow suit but Windows has only just caught up with this (yucky) trend to have dark themes and LCL does not adjust itself.

So, for Windows only I am manually adjusting the colors. Easy for forms and buttons etc but not for menus. The menu's parent is set to the form, the compiler won't let me manually set MenuItems Parent and there is no Color or Font property.

And, yet, a menu's colors do change depending on the OS theme so its not hard coded into the binary.

Any ideas anyone ?



I should have mentioned when saying the "the menu's colors do change" that I mean they change under linux, perhaps its not possible to change them at all under Windows ?


There is an OnDrawItem event for TMainMenu and its items. Does not look perfect, but maybe you can investigate further

Hmm, thats a challenge !

I just had a look at it, I get a chance to change  canvas [Font, Pen, Brush] colors but the event does not seem to be called. With OwnerDraw true or false.  Tried to find where its setup during create and it does not 'seem' (to my uneducated gaze) to be involved at all. I am, currently, using Linux, maybe its only used in (eg) Windows ?

Is it possible that its a unimplemented hook ?


I only tested on Windows where the OnDrawItem is called, but the results were not convincing to me (background not painted over the entire width of the menu bar, bright margin around the area painted, requirement to paint "everything" including icons, checkboxes etc)

Normally I'd recommend to use a third-party menu bar, such as TB2_TBX ( But I cannot run their demo program because of a debugger error.

JVCL has a TJvMainMenu - it has not yet been ported to Lazarus, and, most of all, inherits from TMainMenu and thus will have the same issues as the LCL MainMenu.

Or use TSpkToolbar (disbibuted by Online-Package-Manager) which imitates the new ribbon interface and can be freely modified; there is even a dark theme. But it's not a TMainmenu...


[0] Message Index

[#] Next page

Go to full version