CMenu menu; //创建主菜单项
CMenu* pSubMenu = new CMenu(); //创建子菜单项menu.CreateMenu();
pSubMenu->CreatePopupMenu();
menu.AppendMenu(MF_POPUP,(UINT)pSubMenu->m_hMenu,"文件");
menu.AppendMenu(MF_POPUP,(UINT)pSubMenu->m_hMenu,"编辑"); //问题1:怎样取得新建这个菜单的句柄?
pSubMenu->AppendMenu(MF_STRING,menuID++,"复制");      //问题2:怎样将这个复制菜单项添加到编辑菜单里?2个菜单对象的情况下?文件和编辑是窗口上的可见子菜单
我用过menu.GetSubMenu(2);的方法无法得到新建菜单的句柄!

解决方案 »

  1.   

    The AppendMenu function has been superseded by the InsertMenuItem function. You can still use AppendMenu, however, if you do not need any of the extended features of InsertMenuItem.使用InsertMenuItem添加编辑菜单。
      

  2.   

    CMenu menu, sub_info, sub_control, sub2;
    menu.CreatePopupMenu();
    sub_info.CreatePopupMenu();
    char ip[] = "Item1";
    char name[] = "Item2";sub_info.AppendMenu(MF_STRING, 0, ip);
    sub_info.AppendMenu(MF_STRING, 0, name);
    menu.AppendMenu(MF_POPUP, (UINT)sub_info.m_hMenu, "子菜单");menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
      

  3.   

    1.GetMenu()->GetSubMenu(1)->m_hMenu      //取得第二个子菜单的句柄2.GetMenu()->GetSubMenu(1)->AppendMenu(MF_STRING,1111,"复制");