动态添加子菜单

出处:http://bbs.csdn.net/topics/1206

只要用如下的办法就可以了

HMENU hmenu=CreatePopupMenu(); UINT nEnable=MF_BYPOSITION|MF_POPUP; pMenu->AppendMenu(nEnable,(UINT)hmenu,"新建菜单项"); CMenu *pSubmenu=pMenu->GetSubMenu(pMenu->GetMenuItemCount()-1); nEnable = MF_BYPOSITION|MF_STRING|MF_ENABLED; pMenu->AppendMenu(nEnable,/*菜单的ID号*/10000,m_menurs.m_caption);


其中pMenu为第一层菜单的CMenu指针.pSubmenu为第一层菜单中加入,在pSubmenu中加入
【动态添加子菜单】就是第二层的菜单。


    推荐阅读