动态添加菜单\删除菜单\插入菜单

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(); //重画菜单。





    推荐阅读