Question

Is there a way to change the colors used by plain Win32 menus (background, text, and highlight) for a single process, without using SetSysColors?

(SetSysColors does a global change, which is bad, and if you crash or forget to set the colors back with SetSysColors again before exiting, they will not be restored until you logout.)

Was it helpful?

Solution

If I believe your comment to Rob, it is for a skinned application, with special look and feel. So the way to go is probably indeed, as ferek points out (in an unfriendly way...) to use owner-drawn menus: you will be able to define precisely their look.

OTHER TIPS

The SetMenuInfo() API is your friend. It lets you apply any brush to paint your menu's background.

Something along these lines should solve your problem:

MENUINFO mi = { 0 }; 
mi.cbSize = sizeof(mi); 
mi.fMask = MIM_BACKGROUND|MIM_APPLYTOSUBMENUS; 
mi.hbrBack = hBrush; 

HMENU hMenu = ::GetMenu(hWnd); 
SetMenuInfo(hMenu, &mi); 

I have to ask, why? Adopting the regular Windows look-and-feel is good; it means users can be confident that there are consistent elements in your user interface, onto which they can map their experience using other software for the platform.

[I'm probably preaching to the converted, of course, but I thought I'd make the point so anyone who reads an answer for this doesn't start making all their menus sky-blue-pink 'cause it looks pretty.]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top