1个回答
展开全部
#define IDM_BLUE 5003
#define IDM_GREEN 5002
#define IDM_YELLOW 5004
//WM_CONTEXTMENU消息是在接到WM_RBUTTONUP消息后,由缺省的Windows进程产生
void CSDITestView::OnContextMenu(CWnd* pWnd, CPoint point)
{
CMenu menuPopup; //新建CMenu对象,
if(menuPopup.CreatePopupMenu()) //调用CreatePopupMenu函数将CMenu对象初始化为弹出式菜单
{
//AppendMenu参数:1.菜单风格标识值,2.新菜单项的命令ID,3.指向字符串的指针(缺省为NULL,分隔符)
menuPopup.AppendMenu(MF_STRING,ID_VIEWCOLOR,"颜色(&R)");
//InsertMenu参数:1.菜单项索引或命令ID,2.风格标识(指明第1个参数的意义)
menuPopup.InsertMenu(0,MF_BYPOSITION|MF_STRING,IDM_GREEN,"&Green");
menuPopup.AppendMenu(MF_SEPARATOR);
menuPopup.AppendMenu(MF_STRING|MF_CHECKED,IDM_BLUE,"&Blue");
menuPopup.AppendMenu(MF_STRING|MF_MENUBARBREAK,IDM_YELLOW,"&Yellow");
menuPopup.TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
}
}
#define IDM_GREEN 5002
#define IDM_YELLOW 5004
//WM_CONTEXTMENU消息是在接到WM_RBUTTONUP消息后,由缺省的Windows进程产生
void CSDITestView::OnContextMenu(CWnd* pWnd, CPoint point)
{
CMenu menuPopup; //新建CMenu对象,
if(menuPopup.CreatePopupMenu()) //调用CreatePopupMenu函数将CMenu对象初始化为弹出式菜单
{
//AppendMenu参数:1.菜单风格标识值,2.新菜单项的命令ID,3.指向字符串的指针(缺省为NULL,分隔符)
menuPopup.AppendMenu(MF_STRING,ID_VIEWCOLOR,"颜色(&R)");
//InsertMenu参数:1.菜单项索引或命令ID,2.风格标识(指明第1个参数的意义)
menuPopup.InsertMenu(0,MF_BYPOSITION|MF_STRING,IDM_GREEN,"&Green");
menuPopup.AppendMenu(MF_SEPARATOR);
menuPopup.AppendMenu(MF_STRING|MF_CHECKED,IDM_BLUE,"&Blue");
menuPopup.AppendMenu(MF_STRING|MF_MENUBARBREAK,IDM_YELLOW,"&Yellow");
menuPopup.TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询