project->Add to Project->Compoment->Compomemt->Popup Menu
Easy,using CMenu::CreatePopupMenu() and CMenu::TrackPopupMenu() method you can do it ,a explame such like this:CMenu menu; menu.CreatePopupMenu(); menu.AppendMenu(0,IDC_Test,"&Test"); //add a splitter flag menu.AppendMenu(MF_GRAYED,0,"");//show it CPoint point; GetCursorPos(&point); menu.trackPopupmenu();
menu.CreatePopupMenu();
menu.AppendMenu(0,IDC_Test,"&Test");
//add a splitter flag
menu.AppendMenu(MF_GRAYED,0,"");//show it
CPoint point;
GetCursorPos(&point);
menu.trackPopupmenu();
例如:
void CMainFrame::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
CMenu *pMenu=menu.GetSubMenu(0);
this->m_wndToolBar.ClientToScreen(&point);
pMenu->TrackPopupMenu(TPM_LEFTBUTTON|TPM_LEFTALIGN,point.x,point.y,this);
menu.Detach();
}