다음을 통해 공유


CWnd::GetMenu

이 창에 대 한 메뉴에 대 한 포인터를 검색합니다.

CMenu* GetMenu( ) const;

반환 값

메뉴를 식별합니다. 값 NULL 경우 CWnd 없는 메뉴에 있습니다. 반환 값은 정의 되지 않습니다 CWnd 자식 창입니다.

반환 된 포인터 임시 되어 나중에 사용 하려고 저장 해서는 안됩니다.

설명

메뉴가 없기 때문에이 함수의 자식 창에 대 한 사용 해야 합니다.

예제

void CMainFrame::OnCwndDeletefilemenu()
{
   // This example deletes the leftmost popup menu or leftmost 
   // popup menu item from the application's main window.
   CWnd* pMain = AfxGetMainWnd();

   // The main window _can_ be NULL, so this code 
   // doesn't ASSERT and actually tests. 
   if (pMain != NULL)
   {
      // Get the main window's menu
      CMenu* pMenu = pMain->GetMenu();

      // If there is a menu and it has items, we'll 
      // delete the first one. 
      if (pMenu != NULL && pMenu->GetMenuItemCount() > 0)
      {
         pMenu->DeleteMenu(0, MF_BYPOSITION);
         // force a redraw of the menu bar
         pMain->DrawMenuBar();
      }

      // No need to delete pMenu because it is an MFC 
      // temporary object.
   }
}

요구 사항

헤더: afxwin.h

참고 항목

참조

CWnd 클래스

계층 구조 차트

GetMenu