右键释放的时候,这2个消息
都会响应。
DefWindowProc generates the WM_CONTEXTMENU message when it processes the WM_RBUTTONUP or WM_NCRBUTTONUP message or when the user types SHIFT+F10. The WM_CONTEXTMENU message is also generated when the user presses and releases the VK_APPS key.
可见,
一般WM_RBUTTONUP都会伴随着WM_CONTEXTMENU,但如果收到WM_CONTEXTMENU未必就收到WM_RBUTTONUP,还可能是 WM_NCRBUTTONUP,又可能是按下
SHIFT+F10了。
注意:
WM_CONTEXTMENU
消息产生可能是由鼠标右键按下并释放后产生,也可能是由于键盘按下SHIFT+F10组合键产生,不管那种方式产生的此消息都会使得右键菜单的出现!!!
其他区别在于:
nRButtonDown 中的参数point 是
相对与窗口的左上角坐标(relative to the upper-left corner of the window.MSDN)
OnContextMenu 中的参数point 是
屏幕坐标(Position of the cursor, in screen coordinates)
此外:按下shitf+F10的时候,OnContextMenu中的point为(-1, -1);
右键快捷菜单调用:
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE);
ShowPopupMenu使用:https://blog.csdn.net/cnhk1225/article/details/47725911