-->

How to skin MFC main menu

2019-01-29 11:51发布

问题:

I got a menu in an existing MFC application that has a standard MFC main menu.

But I would like to change its background colour so that it appears to more seamlessly belong to the rest of the application.

  • First picture: An MFC main menu. The application is skinned blue, as seen in the toolbar, but the menu is still standard grey background colour.

  • Second Picture: Spotify's menu, skinned to fit into the rest of the colors.

I have not found any examples on anything similar. Could you please point me towards how to achieve this?

Approaches I thought of:

  1. Subclassing CMenu to my own SkinnedMenu, but it is not created by our code but by a GetMenu() call in a mainframe class deriving from CFrameWnd. The only thing I can find here is its method signature, defined in afxwin.h so then how could I make use my own subclassed menu?

  2. Removing the entire menu and add my own custom menu buttons, in a row, making it look like a menu. Maybe this is what spotify have done, as they have also removed the Windows window frame.

  3. Editing the existing CMenu in some way, but the only customization I am able to find right now is modifying its MENUINFO. For example if I set info.hbrBack = skin.GetSysColorBrush(COLOR_MENU) the only colour that changes is the background of the dropdown, not the main menu itself.

  4. Other :)