共用方式為


CMDIFrameWnd::GetWindowMenuPopup

呼叫此成員函式以取得控制代碼加入至名為「Windows」目前快顯功能表 (具有名為的功能表項目的快顯功能表 MDI 視窗管理的)。

virtual HMENU GetWindowMenuPopup(
   HMENU hMenuBar 
);

參數

  • hMenuBar
    目前的功能表列。

傳回值

視窗快顯功能表,如果存在的話);否則 NULL

備註

預設實作會尋找包含標準視窗功能表命令 (例如 ID_WINDOW_NEWID_WINDOW_TILE_HORZ的快顯功能表。

覆寫這個成員函式已不使用標準命令 ID 的一個視窗功能表。

範例

// 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