简单的方案就是重载文档对象的GetDefaultMenu方法,然后返回你需要的菜单。详细的看下面的解释。===========Create a new menu resource (IDR_MENU2) in the resource editor. Add an HMENU data member to CYourDocument and override GetDefaultMenu() to return this data member: // .h file
// HMENU m_hMyMenu;
// virtual HMENU GetDefaultMenu(); 
HMENU CYourDocument::GetDefaultMenu()
{
return m_hMyMenu; 
}Don't forget to initialize this member variable to NULL in the
constructor or CDocument::OnNewDocument().Change and redraw the menu at the desired times. For example,when new child frame is creating. The following code shows how to implement it in OnInitialUpdate function. // example within CView OnInitialUpdate function
((CYourDocument*)GetDocument())->m_hMyMenu = ::LoadMenu(
AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MENU2));
((CFrameWnd*)AfxGetMainWnd())->OnUpdateFrameMenu(NULL);
AfxGetMainWnd()->DrawMenuBar();Be sure to destroy the menu upon exiting the application, and avoid having too many menus loaded at once. Menus can also be switched simply by changing the value of [ccode]
CMDIChildWnd::m_hMenuShared (MDI) ,but GetDefaultMenu() is more robust.