I don’t know how, but it seems that when the main menu of a window is opened, the main message loop (PeekMessage/GetMessage, etc…) in my program stops. The behavior seems to be much like if a modal dialog was opened, because my WindowProc still gets called when messages arrive, so there must be some other message loop somewhere keeping that happening.
I don’t know how that happens yet (did not test yet), which function or message blocks the main message loop, I am guessing it happens somewhere in the DefWindowProc for some message which has to do with opening the menu.
Is this the default behavior of main menu on Windows? What is really the point of this in that case? Can it be changed so that the main message loop will keep running, instead of some internal one?
I was wrong, so I’ve updated this answer.
Windows normally enters an internal modal message loop while it is displaying a menu. The WM_ENTERMENULOOP message notifies you when Windows enters this loop.
You can make a menu modeless by setting the
MNS_MODELESSflag. For example, you can do it to windowhWndthus:Unfortunately, this causes your main window to lose activation when a menu is opened, which is visually distracting. The second part of this answer explains how menus avoid this problem in the modal case. This answer hints at a solution; you need to interfere with the
WM_NCACTIVATEmessage so that the appearance of the main window is out of sync with its activation.