转自MSDNhttps://msdn.microsoft.com/zh-cn/library/7xkd69hf.aspx
void CMainFrame::OnCwndDeletefilemenu() { // This example deletes the leftmost popup menu or leftmost // popup menu item from the application's main window. CWnd* pMain = AfxGetMainWnd(); // The main window _can_ be NULL, so this code // doesn't ASSERT and actually tests. if (pMain != NULL) { // Get the main window's menu CMenu* pMenu = pMain->GetMenu(); // If there is a menu and it has items, we'll // delete the first one. if (pMenu != NULL && pMenu->GetMenuItemCount() > 0) { pMenu->DeleteMenu(0, MF_BYPOSITION); // force a redraw of the menu bar pMain->DrawMenuBar(); } // No need to delete pMenu because it is an MFC // temporary object. } }
本文提供了一个C++示例代码,展示了如何从应用程序的主窗口中删除最左侧的弹出菜单或菜单项。通过获取主窗口及菜单,利用CMenu类的方法DeleteMenu实现删除操作,并重新绘制菜单栏。
1443

被折叠的 条评论
为什么被折叠?



