Draw a menu (not popup menu) in any rectangular region of a window with MFC

menumfc

I override OnNcPaint() method along with OnNcLButtonDown() and OnNcMouseMove() and OnNcHitTest() method. So the original menu of the window doesn't exist. I want to add a menu with the area of the caption bar. How can I do this?

Thank you very much!

Best Solution

The menu is painted as part of the non-client area. So if you are doing your own non-client painting, you'll also have to draw the window yourself. You may be able to hack something out with TrackPopupMenu to do the actual menu drawing, and you'll just have to handle the menu bar and top-level menu items yourself.

Drawing the non-client area yourself is fraught with peril. Are you sure you don't just want to use an owner drawn menu?

It can be tempting to tweak your UI dialogs to fit your exact needs, but also keep in mind that it is jarring to users who are accustomed to the look-and-feel of windows already.

Related Question