CMDIFrameWnd::GetWindowMenuPopup

调用该成员函数使用属性获取名为“窗口的”当前弹出菜单(与菜单项的弹出菜单MDI窗口托管)。

virtual HMENU GetWindowMenuPopup(
   HMENU hMenuBar 
);

参数

  • hMenuBar
    当前菜单栏。

返回值

窗口弹出菜单,如果存在);否则 NULL

备注

默认实现查找包含标准windows菜单命令例如 ID_WINDOW_NEWID_WINDOW_TILE_HORZ的一个弹出菜单。

重写此成员函数,或者不使用标准命令ID的一个windows菜单。

示例

// CMainFrame::OnActivateFirstMDIChild() is a menu command handler for
// CMainFrame class, which in turn is a CMDIFrameWnd-derived class.
// It looks for the caption of the first created MDI child window from
// the Window popup menu, and then activate the child window.
void CMainFrame::OnActivateFirstMDIChild() 
{
   // Get handle to the Window pop-up menu.
   CMenu* menubar = GetMenu();
   CMenu* wmenu = CMenu::FromHandle(GetWindowMenuPopup(menubar->GetSafeHmenu()));
   if (wmenu == NULL)
      return;

   // Get the caption of the first created MDI child window.
   CString caption;
   if (!wmenu->GetMenuString(AFX_IDM_FIRST_MDICHILD, caption, MF_BYCOMMAND))
      return;

   // Get the actual name of the first created MDI child window by 
   // getting rid of the number and space, e.g. "&1 MDI 1".
   int pos = caption.FindOneOf(_T(" "));
   if (pos == -1)
      return;

   caption = caption.Right(caption.GetLength() - (pos + 1));

   // Get the CWnd* of the first created MDI child window by comparing
   // the caption of each MDI child window in the MDI application. 
   // Activate the first created MDI child window if found.
   CMDIChildWnd* child = MDIGetActive();
   do
   {
      CString str;
      child->GetWindowText(str);
      if (str == caption)
      {
         child->MDIActivate();        // or MDIActivate(child);
         break;
      }

      child = (CMDIChildWnd*) child->GetWindow(GW_HWNDNEXT);
   }
   while (child);
}

要求

Header: afxwin.h

请参见

参考

CMDIFrameWnd选件类

层次结构图

CMDIFrameWnd::MDIGetActive