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?
1
votes
1 Answers
3
votes
Yes, this is by design. The OnMenuSelect
method corresponds to the WM_MENUSELECT
message, 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_COMMAND
message, which is
Sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
In MFC terms, this means overriding the OnCommand
method:
The framework calls this member function when the user selects an item from a menu, when a child control sends a notification message, or when an accelerator keystroke is translated.