MFC 右键菜单

CMenu   m_PopMenu;

this->SetForegroundWindow(); //在弹出菜单之前,将你的程序设置为前端窗口。 这样可以保证弹出菜单后无法关闭的问题
m_PopMenu.LoadMenu(IDR_MENU_RIGHTVIEW);   //装入你相应的菜单资源
POINT   Pt;
GetCursorPos(&Pt);
m_PopMenu.GetSubMenu(0)-> TrackPopupMenu(
      TPM_LEFTALIGN|TPM_RIGHTBUTTON,Pt.x,Pt.y,AfxGetApp()-> GetMainWnd());

猜你喜欢

转载自paulfzm.iteye.com/blog/930211