示例#1
0
void CMDIChildWnd::OnMDIActivate( BOOL bActivate, CWnd *pActivateWnd,
                                  CWnd *pDeactivateWnd )
/******************************************************/
{
    UNUSED_ALWAYS( pDeactivateWnd );

    CView *pView = GetActiveView();
    if( pView != NULL ) {
        if( !bActivate ) {
            pView->OnActivateView( FALSE, pView, pView );
        } else {
            pView->OnActivateView( TRUE, pView, pView );
        }
    }

    OnUpdateFrameMenu( bActivate, pActivateWnd, NULL );
    CMDIFrameWnd *pFrame = GetMDIFrame();
    ASSERT( pFrame != NULL );
    pFrame->DrawMenuBar();
}
示例#2
0
void CFrameWnd::SetActiveView( CView *pViewNew, BOOL bNotify )
/************************************************************/
{
    if( m_pViewActive != pViewNew ) {
        CView *pViewOld = m_pViewActive;
        if( pViewOld != NULL ) {
            pViewOld->OnActivateView( FALSE, pViewNew, pViewOld );
        }
        m_pViewActive = pViewNew;
        if( bNotify && pViewNew != NULL ) {
            pViewNew->OnActivateView( TRUE, pViewNew, pViewOld );
        }
    }
}
示例#3
0
void CMDIChildWnd::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd*)
{
	m_bPseudoInactive = FALSE;  // must be happening for real

	// make sure MDI client window has correct client edge
	UpdateClientEdge();

	// send deactivate notification to active view
	CView* pActiveView = GetActiveView();
	if (!bActivate && pActiveView != NULL)
		pActiveView->OnActivateView(FALSE, pActiveView, pActiveView);

	// allow hook to short circuit normal activation
	BOOL bHooked = FALSE;
#ifndef _AFX_NO_OLE_SUPPORT
	if (m_pNotifyHook != NULL && m_pNotifyHook->OnDocActivate(bActivate))
		bHooked = TRUE;
#endif

	// update titles (don't AddToTitle if deactivate last)
	if (!bHooked)
		OnUpdateFrameTitle(bActivate || (pActivateWnd != NULL));

	// re-activate the appropriate view
	if (bActivate)
	{
		if (pActiveView != NULL && GetMDIFrame() == GetActiveWindow())
			pActiveView->OnActivateView(TRUE, pActiveView, pActiveView);
	}

	// update menus
	if (!bHooked)
	{
		OnUpdateFrameMenu(bActivate, pActivateWnd, NULL);
		GetMDIFrame()->DrawMenuBar();
	}
}
示例#4
0
BOOL CView::DoPrintPreview(UINT nIDResource, CView* pPrintView,
	CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState)
{
	ASSERT_VALID_IDR(nIDResource);
	ASSERT_VALID(pPrintView);
	ASSERT(pPreviewViewClass != NULL);
	ASSERT(pPreviewViewClass->IsDerivedFrom(RUNTIME_CLASS(CPreviewView)));
	ASSERT(pState != NULL);

	CFrameWnd* pParent = (CFrameWnd*)AfxGetThread()->m_pMainWnd;
	ASSERT_VALID(pParent);
	ASSERT_KINDOF(CFrameWnd, pParent);

	CCreateContext context;
	context.m_pCurrentFrame = pParent;
	context.m_pCurrentDoc = GetDocument();
	context.m_pLastView = this;

	// Create the preview view object
	CPreviewView* pView = (CPreviewView*)pPreviewViewClass->CreateObject();
	if (pView == NULL)
	{
		TRACE0("Error: Failed to create preview view.\n");
		return FALSE;
	}
	ASSERT_KINDOF(CPreviewView, pView);
	pView->m_pPreviewState = pState;        // save pointer

	pParent->OnSetPreviewMode(TRUE, pState);    // Take over Frame Window

#ifdef _MAC
	if (nIDResource == AFX_IDD_PREVIEW_TOOLBAR)
	{
		HINSTANCE hInst = AfxFindResourceHandle(
			MAKEINTRESOURCE(AFX_IDD_PREVIEW_TOOLBAR), RT_DIALOG);
		HRSRC hResource = FindResource(hInst,
			MAKEINTRESOURCE(AFX_IDD_PREVIEW_TOOLBAR), RT_DIALOG);

		HGLOBAL hdt = NULL;
		if (hResource != NULL)
			hdt = LoadResource(hInst, hResource);

		DLGTEMPLATE* pdt = NULL;
		if (hdt != NULL)
			pdt = (DLGTEMPLATE*)LockResource(hdt);

		if (pdt != NULL)
		{
			CRect rectParent;
			pParent->GetClientRect(&rectParent);

			int cxToolbar = MulDiv(LOWORD(GetDialogBaseUnits()), pdt->cx, 4);

			if (cxToolbar > rectParent.Width())
				nIDResource = AFX_IDD_PREVIEW_SHORTTOOLBAR;

			UnlockResource(hdt);
			FreeResource(hdt);
		}
	}
#endif

	// Create the toolbar from the dialog resource
	pView->m_pToolBar = new CDialogBar;
	if (!pView->m_pToolBar->Create(pParent, MAKEINTRESOURCE(nIDResource),
		CBRS_TOP, AFX_IDW_PREVIEW_BAR))
	{
		TRACE0("Error: Preview could not create toolbar dialog.\n");
		pParent->OnSetPreviewMode(FALSE, pState);   // restore Frame Window
		delete pView->m_pToolBar;       // not autodestruct yet
		pView->m_pToolBar = NULL;
		pView->m_pPreviewState = NULL;  // do not delete state structure
		delete pView;
		return FALSE;
	}
	pView->m_pToolBar->m_bAutoDelete = TRUE;    // automatic cleanup

	// Create the preview view as a child of the App Main Window.  This
	// is a sibling of this view if this is an SDI app.  This is NOT a sibling
	// if this is an MDI app.

	if (!pView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
		CRect(0,0,0,0), pParent, AFX_IDW_PANE_FIRST, &context))
	{
		TRACE0("Error: couldn't create preview view for frame.\n");
		pParent->OnSetPreviewMode(FALSE, pState);   // restore Frame Window
		pView->m_pPreviewState = NULL;  // do not delete state structure
		delete pView;
		return FALSE;
	}

	// Preview window shown now

	pState->pViewActiveOld = pParent->GetActiveView();
	CView* pActiveView = pParent->GetActiveFrame()->GetActiveView();
	if (pActiveView != NULL)
		pActiveView->OnActivateView(FALSE, pActiveView, pActiveView);

	if (!pView->SetPrintView(pPrintView))
	{
		pView->OnPreviewClose();
		return TRUE;            // signal that OnEndPrintPreview was called
	}

	pParent->SetActiveView(pView);  // set active view - even for MDI

	// update toolbar and redraw everything
	pView->m_pToolBar->SendMessage(WM_IDLEUPDATECMDUI, (WPARAM)TRUE);
	pParent->RecalcLayout();            // position and size everything
	pParent->UpdateWindow();

	return TRUE;
}