Home > Enterprise >  How to detect a CMenu visiable or not in MFC?
How to detect a CMenu visiable or not in MFC?

Time:09-29

I'm making a right click menu in my application. And I want to check whether the menu is shown or not. But I read the Microsoft docs of CMenu and fount that there is no way to make it. How to get the menu state, and is there any way to get the menu disappear event?

CodePudding user response:

The system sends a WM_ENTERMENULOOP message to a menu's owner window whenever a menu is about to be shown, and a WM_EXITMENULOOP message after it has been dismissed.

Those messages map to the CWnd::OnEnterMenuLoop and CWnd::OnExitMenuLoop message handlers that your code can override to keep track of the menu state. The bIsTrackPopupMenu argument is set to TRUE for a popup menu.

  • Related