1

I'm displaying a popup menu using TrackPopupMenu and would like to know when it is dismissed via clicking outside of it. I've looked through all the menu functions but didn't find anything useful in this regard. Spy++ told me that no window message is sent in this case.

So, is there an easy way to do it without installing a mouse hook? Thanks!

4

1 回答 1

3

[编辑]
这更好。如果在 uFlags 参数中指定 TPM_RETURNCMD,则返回值是用户选择的项目的菜单项标识符。如果用户在没有选择的情况下取消菜单,或者如果发生错误,则返回值为零。

当 ::TrackPopupMenu() 返回时,菜单循环结束:) 如果选择了菜单项,则将 HWND 作为第 6 个参数传递的窗口将收到带有所选项目 ID 的 WM_COMMAND 消息。在 ::TrackPopupMenu() 返回后,您可能可以 ::PeekMessage() 查看 WM_COMMAND 是否在队列中。

如果您想在 ::TrackPopupMenu() 中收到通知,您可以处理 WM_EXITMENULOOP。

于 2010-03-17T09:49:42.040 回答