TrackPopupMenu and left click notification
I have a window that displays a context menu, so I call TrackPopupMenu (with the TPM_NONOTIFY and TPM_RETURNCMD flags). As far as I can tell, the TrackPopupMenu function captures mouse input until the user selects a menu item or clicks somewhere outside of the menu. Then the function returns the id of the menu item that was selected, or 0 if the menu was canceled, and I do whatever to handle the option they selected. So far so good.
However, if the user right clicks to show the context menu, and then left clicks somewhere on the window (not on the menu), not only does the menu get cancelled, but the window also receives a WM_LBUTTONDOWN message. Is this standard Windows behavior? If so, is there a good way to ignore the mouse event that caused the menu to be cancelled?
Thanks for any help!
Kelly
[838 byte] By [
Runt888] at [2007-11-19 22:46:39]

# 1 Re: TrackPopupMenu and left click notification
Well, I was able to get the behavior I wanted by setting a boolean flag before I opened the menu, then resetting it on the left mouse button down or esc key press. However, it seems kind of hacky to me, so I'd definately like to know any good ideas people have.
Kelly
# 2 Re: TrackPopupMenu and left click notification
Well, what you're doing in the WM_LBUTTONDOWN handler that can't be done when the menu exist/is closed?
kkez at 2007-11-9 13:23:36 >

# 3 Re: TrackPopupMenu and left click notification
Well, I was able to get the behavior I wanted by setting a boolean flag before I opened the menu, then resetting it on the left mouse button down or esc key press. However, it seems kind of hacky to me, so I'd definately like to know any good ideas people have.
Kelly
What if the user closed the menu by using keyboard only ?
# 4 Re: TrackPopupMenu and left click notification
What if the user closed the menu by using keyboard only?
I also test for the ESC key. Is there another way to close the menu from the keyboard?