CMenu close notification
-
I created a context menu and displayed it using
TrackPopupMenu
. I do not useTPM_RETURNCMD
. My application window receives the result of user selection. It works fine if I select/click some menu item - the window receives message for the given menu item. However if I cancel the context menu (hit Esc or click somewhere else) I do not receive any message. Is there any mechanism to catch context menu cancel event? Another question, how to determine if a context menu (CMenu) is active and displayed? Thanks, Abyss -
I created a context menu and displayed it using
TrackPopupMenu
. I do not useTPM_RETURNCMD
. My application window receives the result of user selection. It works fine if I select/click some menu item - the window receives message for the given menu item. However if I cancel the context menu (hit Esc or click somewhere else) I do not receive any message. Is there any mechanism to catch context menu cancel event? Another question, how to determine if a context menu (CMenu) is active and displayed? Thanks, AbyssTrackPopupMenu will return 0 if user cancels the menu.
Abyss wrote:
Another question, how to determine if a context menu (CMenu) is active and displayed?
If you call the TrackPopupMenu, the thread is blocked at that statement as long as the menu is displayed. So from where you want to know the state of menu?
nave [OpenedFileFinder]
-
TrackPopupMenu will return 0 if user cancels the menu.
Abyss wrote:
Another question, how to determine if a context menu (CMenu) is active and displayed?
If you call the TrackPopupMenu, the thread is blocked at that statement as long as the menu is displayed. So from where you want to know the state of menu?
nave [OpenedFileFinder]
If I call
TrackPopupMenu
withTPM_RETURNCMD
flag then the thread is blocked and I can check the return value. However I do not use theTPM_RETURNCMD
flag which cause that theTrackPopupMenu
creates the context menu and immediately exits. The menu is still active and sending messages to the window. That is why I can't check the return flag because it just say that the menu has been created. Abyss -
If I call
TrackPopupMenu
withTPM_RETURNCMD
flag then the thread is blocked and I can check the return value. However I do not use theTPM_RETURNCMD
flag which cause that theTrackPopupMenu
creates the context menu and immediately exits. The menu is still active and sending messages to the window. That is why I can't check the return flag because it just say that the menu has been created. AbyssAbyss wrote:
If I call TrackPopupMenu with TPM_RETURNCMD flag then the thread is blocked and I can check the return value
I dont think so. please try putting a messagebox in the next line after the
TrackPopupMenu()
and see whether it is coming or not.nave [OpenedFileFinder]
-
Abyss wrote:
If I call TrackPopupMenu with TPM_RETURNCMD flag then the thread is blocked and I can check the return value
I dont think so. please try putting a messagebox in the next line after the
TrackPopupMenu()
and see whether it is coming or not.nave [OpenedFileFinder]
-
TrackPopupMenu will return 0 if user cancels the menu.
Abyss wrote:
Another question, how to determine if a context menu (CMenu) is active and displayed?
If you call the TrackPopupMenu, the thread is blocked at that statement as long as the menu is displayed. So from where you want to know the state of menu?
nave [OpenedFileFinder]
Naveen wrote:
TrackPopupMenu will return 0 if user cancels the menu.
Only if the TPM_RETURNCMD is specified. If not it will return the success or failure status. See the MSDN documentaion. If you specify TPM_RETURNCMD in the fuFlags parameter, the return value is the menu-item identifier of the item that the user selected. If the user cancels the menu without making a selection, or if an error occurs, then the return value is 0. If you do not specify TPM_RETURNCMD in the fuFlags parameter, the return value is nonzero if the function succeeds and 0 if it fails. To get extended error information, call GetLastError.
- NS - [ODBaseBtn]