Dynamic menu using mfc

后端 未结 4 1220
北恋
北恋 2020-12-03 05:40

I would like to add a menu item to my main menu and then populate it with items at run time. How would I do this? And besides adding items how would I have a message map en

4条回答
  •  旧巷少年郎
    2020-12-03 06:09

      CMenu menuPopup;
      menuPopup.LoadMenu(IDR_CNTXT_PLAN);
    subMenu.CreatePopupMenu();
     subMenu.AppendMenu(MF_STRING, MENU1,"Menu1");
    subMenu.AppendMenu(MF_STRING, MENU2,"Menu2");
    CMenu* pMenu = menuPopup.GetSubMenu(0);
      pMenu->InsertMenu(0,MF_BYPOSITION|MF_POPUP,(UINT)subMenu.m_hMenu,"Layers");
      menuPopup.GetSubMenu(0)->InsertMenu(1,MF_BYPOSITION|MF_SEPARATOR,0,"");
    menuPopup.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
    

提交回复
热议问题