Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom menu border in pure Win32 C++ (w/o WTL, MFC, etc)

Using only Win32 C++ (no WTL or MFC or any other third-party library), how can I get custom menu borders?

I was able to ownerdrawn the items but the borders are in the Non Client area and I was unable to find a way change them.

Is there a way?

like image 709
AP. Avatar asked Dec 27 '13 19:12

AP.


1 Answers

No matter how you implement this it is going to be a bit of a hack.

One option is to forget about HMENUs and build your own menus with a custom always on top window. This is probably way too much work and you will never get everything perfect. Just off the top of my head you have to deal with LTR vs. RTL, accessibility, configurable settings like the shadow and menu animations (sliding/fading). There are probably things SetMenu does to a HWND that you cannot replicate with a hack like this but you can sidestep that issue by implementing it in a rebar.

If you want to keep using HMENUs then you have to use SetWindowsHookEx to find the menus HWND. The menu class is #32768. You can then subclass the window and override the WM_NC* and WM_PRINT* messages. This Codeproject article also has information about a undocumented message (0x01e5) you need to handle.

like image 136
Anders Avatar answered Nov 16 '22 04:11

Anders