Ejemplo n.º 1
0
void CMDIChildWnd::OnUpdateFrameMenu( BOOL bActive, CWnd *pActivateWnd, HMENU hMenuAlt )
/**************************************************************************************/
{
    CMDIFrameWnd *pFrame = GetMDIFrame();
    ASSERT( pFrame != NULL );

    if( hMenuAlt == NULL ) {
        hMenuAlt = m_hMenuShared;
    }
    
    if( bActive ) {
        ::SendMessage( pFrame->m_hWndMDIClient, WM_MDISETMENU, (WPARAM)hMenuAlt,
                       (LPARAM)pFrame->GetWindowMenuPopup( hMenuAlt ) );
    } else if( pActivateWnd == NULL ) {
        ::SendMessage( pFrame->m_hWndMDIClient, WM_MDISETMENU,
                       (WPARAM)pFrame->m_hMenuDefault, NULL );
    }
}
Ejemplo n.º 2
0
void CMDIChildWnd::OnUpdateFrameMenu(BOOL bActivate, CWnd* pActivateWnd,
	HMENU hMenuAlt)
{
	CMDIFrameWnd* pFrame = GetMDIFrame();

	if (hMenuAlt == NULL && bActivate)
	{
		// attempt to get default menu from document
		CDocument* pDoc = GetActiveDocument();
		if (pDoc != NULL)
			hMenuAlt = pDoc->GetDefaultMenu();
	}

	// use default menu stored in frame if none from document
	if (hMenuAlt == NULL)
		hMenuAlt = m_hMenuShared;

	if (hMenuAlt != NULL && bActivate)
	{
		ASSERT(pActivateWnd == this);

		// activating child, set parent menu
		::SendMessage(pFrame->m_hWndMDIClient, WM_MDISETMENU,
			(WPARAM)hMenuAlt, (LPARAM)pFrame->GetWindowMenuPopup(hMenuAlt));
	}
	else if (hMenuAlt != NULL && !bActivate && pActivateWnd == NULL)
	{
		// destroying last child
		HMENU hMenuLast = NULL;
		::SendMessage(pFrame->m_hWndMDIClient, WM_MDISETMENU,
			(WPARAM)pFrame->m_hMenuDefault, (LPARAM)hMenuLast);
	}
	else
	{
		// refresh MDI Window menu (even if non-shared menu)
		::SendMessage(pFrame->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0);
	}
}