我的程序里有一个窗口(W)菜单,每当打开一个新的视图时,会在窗口(W)下动态生成一个对应视图的菜单。现在我在窗口(W)后面的帮助(H)菜单后又增加了一个测试(T)菜单,打开视图时,动态生成的菜单加到帮助(H)下了,而没有在窗口(W)。
这个功能不知道FMC是如何产生的,也就不知道如何修改。

解决方案 »

  1.   

    动态合并菜单,然后用SetMenu设置到主窗口上。
      

  2.   

    多文档框架特别提供了个参数来替换菜单 CMDIFrameWnd::MDISetMenu
      

  3.   

    该函数的用法,例如
    void CMdiView::OnReplaceMenu() 
    {
       // Load a new menu resource named IDR_SHORT_MENU. m_DefaultMenu is 
       // a member variable of CMdiDoc class (a CDocument-derived class). 
       // Its type is HMENU.
       CMdiDoc* pdoc = GetDocument();
       pdoc->m_DefaultMenu = 
          ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_SHORT_MENU));
       if (pdoc->m_DefaultMenu == NULL)
          return;   // Get the parent window of this view window. The parent window is
       // a CMDIChildWnd-derived class. We can then obtain the MDI parent 
       // frame window using the CMDIChildWnd*. Then, replace the current 
       // menu bar with the new loaded menu resource.
       CMDIFrameWnd* frame = ((CMDIChildWnd *) GetParent())->GetMDIFrame();
       frame->MDISetMenu(CMenu::FromHandle(pdoc->m_DefaultMenu), NULL);
       frame->DrawMenuBar();
    }