void CMenuView::OnRButtonDown(UINT nFlags, CPoint point) { //弹出菜单 /* CMenu menu; menu.LoadMenu(IDR_MENU_POPUP); CMenu *pMenu = menu.GetSubMenu(0); //ScreenToClient(&point); ClientToScreen(&point); pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,this); */ CView::OnRButtonDown(nFlags, point); } void CMenuView::OnContextMenu(CWnd* pWnd, CPoint point) { if(point.x==-1 && point.y == -1){ CRect rect; GetClientRect(&rect); point =rect.TopLeft(); ClientToScreen(&point); point.Offset(5,5); } CMenu menu; menu.LoadMenu(IDR_MENU_POPUP); CMenu *pMenu = menu.GetSubMenu(0); //ClientToScreen(&point); pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,this); }