Condividi tramite


CMDIFrameWnd::GetWindowMenuPopup

Chiamare la funzione membro per ottenere un handle al menu di scelta rapida corrente denominato "windows" (il menu di scelta rapida alle voci di menu per la gestione della finestra MDI).

virtual HMENU GetWindowMenuPopup( 
   HMENU hMenuBar  
);

Parametri

  • hMenuBar
    La barra dei menu corrente.

Valore restituito

Il menu di scelta rapida della finestra se disponibile; in caso contrario NULL.

Note

L'implementazione predefinita cerca un menu di scelta rapida contenente i comandi di menu standard della finestra come ID_WINDOW_NEW e ID_WINDOW_TILE_HORZ.

Eseguire l'override della funzione membro in una finestra che non utilizza il comando di menu standard è.

Esempio

// 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);
}

Requisiti

Header: afxwin.h

Vedere anche

Riferimenti

Classe CMDIFrameWnd

Grafico delle gerarchie

CMDIFrameWnd::MDIGetActive