CMenu MyMenu,poPumenu;
/*MyMenu.CreateMenu();
MyMenu.AppendMenuA(MF_STRING,IDM_MENU0,"文件");
MyMenu.AppendMenuA(MF_STRING,IDM_MENU1,"编辑");
MyMenu.AppendMenuA(MF_STRING,IDM_MENU2,"查看");
MyMenu.AppendMenuA(MF_STRING,IDM_MENU3,"帮助");
MyMenu.InsertMenuA(IDM_MENU2,MF_BYCOMMAND,IDM_ITEM0,"有关");
this->SetMenu(&MyMenu);
MyMenu.Detach();
*/
poPumenu.CreatePopupMenu();
//添加弹出菜单
// GetMenu()->AppendMenuA(MF_POPUP,(UINT)poPumenu.m_hMenu,"win32");
//插入菜单
GetMenu()->InsertMenuA(2,MF_BYPOSITION|MF_POPUP,(UINT)poPumenu.m_hMenu,"win32");
//往菜单中插入菜单
// poPumenu.AppendMenuA(MF_STRING,ID_FILE_TEST1,"TEST1");
poPumenu.AppendMenuA(MF_STRING,124,"TEST2");
poPumenu.AppendMenuA(MF_STRING,125,"TEST3");
GetMenu()->GetSubMenu(0)->AppendMenuA(MF_STRING,126,"TEST4");
//根据索引
//GetMenu()->GetSubMenu(0)->InsertMenuA(2,MF_BYPOSITION|MF_STRING,127,"TEST5");
//根据ID号
// GetMenu()->GetSubMenu(0)->InsertMenuA(ID_FILE_OPEN,MF_BYCOMMAND,128,"TEST6");
//删除菜单
GetMenu()->GetSubMenu(0)->DeleteMenu(0,MF_BYPOSITION);
poPumenu.Detach();
【动态添加菜单\删除菜单\插入菜单】
DrawMenuBar();
//重画菜单。
推荐阅读
- MFC中CString、char*、int、COleDateTime之间的转换
- MFC_string与CString之间互相转换
- MFC_解决UpdateData(FALSE)在循环中失效问题
- MFC|gdal 图像金字塔
- GDAL保存图像文件
- 图像处理|GDI+图像处理学习笔记——改变图像的透明度
- C++|MFC中OnMouseWheel不触发的原因之一
- 初学|关于控件ID的学习心得
- mfc DDX_TEXT() 和 DDX_Control()