I have an application with a context menu. I use the OnMenuSelect method but it gets invoked when mouse is over the menu item, not when I click on it. Is there a method to solve this problem?
I have an application with a context menu. I use the OnMenuSelect method but
Share
Yes, this is by design. The
OnMenuSelectmethod corresponds to theWM_MENUSELECTmessage, which is sent whenever the mouse is hovering over a menu item.To handle a click event for a menu item, you need to process the
WM_COMMANDmessage, which isIn MFC terms, this means overriding the
OnCommandmethod: