第一段代码:
void CMyDrawView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y,this);//可以让菜单跟踪鼠标左键或右键还可以选择对其方式
}
第二段代码:
void CMyDrawView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y,AfxGetMainWnd());//可以让菜单跟踪鼠标左键或右键还可以选择对其方式
}执行效果反正是不一样,谁能告诉我这里面到底有什么区别?消息是怎样传递的?
void CMyDrawView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y,this);//可以让菜单跟踪鼠标左键或右键还可以选择对其方式
}
第二段代码:
void CMyDrawView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y,AfxGetMainWnd());//可以让菜单跟踪鼠标左键或右键还可以选择对其方式
}执行效果反正是不一样,谁能告诉我这里面到底有什么区别?消息是怎样传递的?
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y,this)
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y,AfxGetMainWnd());
最后一参数,请参阅MSDN对这个参数的说明:
Handle to the window that owns the shortcut menu. This window receives all messages from the menu. The window does not receive a WM_COMMAND message from the menu until the function returns.
If you specify TPM_NONOTIFY in the uFlags parameter, the function does not send messages to the window identified by hWnd. However, you must still pass a window handle in hWnd. It can be any window handle from your application.
简单的说就由mune发出的消息由哪个窗口接收处理