1个回答
展开全部
视图类添加右键菜单消息WM_CONTEXTMENU
MSDN中事例
void CDrawView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
// make sure window is active
GetParentFrame()->ActivateFrame();
CPoint local = point;
ScreenToClient(&local);
ClientToDoc(local);
CDrawObj* pObj;
pObj = GetDocument()->ObjectAt(local);
if (pObj != NULL)
{
if (!IsSelected(pObj))
Select(pObj, FALSE);
UpdateWindow();
CMenu menu;
if (menu.LoadMenu(ID_POPUP_MENU))
{
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y,
AfxGetMainWnd()); // use main window for cmds
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询