Article ID: 139469
Article Last Modified on 11/21/2006
void CMyView::OnRButtonUp(UINT nFlags, CPoint point)
{
// Calling the base class function.
CView::OnRButtonUp(nFlags, point);
// Get the top level menu from the main application window.
CWnd* pMainWindow = AfxGetMainWnd();
CMenu* pTopLevelMenu = pMainWindow->GetMenu();
// Get the File popup menu from the top level menu.
CMenu *pFileMenu = pTopLevelMenu->GetSubMenu(0);
// Convert the mouse location to screen coordinates before passing
// it to the TrackPopupMenu() function.
ClientToScreen(&point);
// Display the File popup menu as a floating popup menu in the
// client area of the main application window.
pFileMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
point.x,
point.y,
pMainWindow); // owner is the main application window
}
Additional query words: kbinf 2.00 2.10 2.20 2.51 2.52 3.00 3.10 3.20 4.00 4.10
Keywords: kbcode kbhowto kbmenu kbuidesign KB139469