点击鼠标左键会出现弹式菜单:
▲ 弹出菜单//鼠标左键按下
void CMy05_MenuView::OnLButtonDown(UINT nFlags, CPoint point)
{
//获取主菜单
//CMenu *menu = GetMenu(); // 这个会直接报错
//创建菜单项 需要新创建一个,不能再视图直接获取框架的那个菜单
CMenu menu;
menu.LoadMenuW(IDR_MENU1);
//获取子菜单
CMenu *subMenu = menu.GetSubMenu(0);
//subMenu->CheckMenuItem(0, MF_BYPOSITION | MF_CHECKED);
ClientToScreen(&point); // 坐标转换
//子菜单作为快捷菜单,右击菜单
subMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
point.x, point.y, this);
CView::OnLButtonDown(nFlags, point);
}
标签:右击,subMenu,菜单,point,menu,CMenu,右键
From: https://www.cnblogs.com/huvjie/p/17991146