CMDIFrameWnd::GetWindowMenuPopup
"창" (MDI 창 관리에 대 한 메뉴 항목 팝업 메뉴) 라는 현재 팝업 메뉴에 대 한 핸들을 얻으려면이 멤버 함수를 호출 합니다.
virtual HMENU GetWindowMenuPopup(
HMENU hMenuBar
);
매개 변수
- hMenuBar
현재 메뉴 모음입니다.
반환 값
창 팝업 메뉴 중 하나에 있습니다. 그렇지 않으면 NULL.
설명
기본 구현은 표준 창 메뉴 명령 같이 포함 된 팝업 메뉴의 보이는 ID_WINDOW_NEW 및 ID_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);
}
요구 사항
헤더: afxwin.h