PRB: Print Preview Displays in MDI Child FrameLast reviewed: June 16, 1997Article ID: Q166135 |
The information in this article applies to:
SYMPTOMSWhen you display print preview for an MDI application, the preview view is displayed in the MDI child window rather than the MDI frame window.
CAUSEThe MFC sources were changed to fix a bug when mixing Active X documents and print preview.
RESOLUTIONRebuild the MFC libraries and statically link to it.
STATUSThis behavior is by design.
MORE INFORMATIONWhen MFC's print preview is invoked, it searches for the frame window of the current view using GetParentFrame to display the preview view. This is done in CView::DoPrintPreview. The code below reflects some of the changes that DoPrintPreview went through between Visual C++ 4.2 and 5.0.
// VC 4.2 BOOL CView::DoPrintPreview(UINT nIDResource, CView* pPrintView, CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState) { ... CFrameWnd* pParent = (CFrameWnd*)AfxGetThread()->m_pMainWnd; ASSERT_VALID(pParent); ASSERT_KINDOF(CFrameWnd, pParent); ... } // VC 5.0 BOOL CView::DoPrintPreview(UINT nIDResource, CView* pPrintView, CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState) { ... CFrameWnd* pParent; CWnd* pNaturalParent = pPrintView->GetParentFrame(); pParent = DYNAMIC_DOWNCAST(CFrameWnd, pNaturalParent); if (pParent == NULL || pParent->IsIconic()) pParent = (CFrameWnd*)AfxGetThread()->m_pMainWnd; ... }In Visual C++ 4.2b, the preview view may not always appear in the MDI child frame. If the view is not an immediate child of the MDI child frame (for example, splitter windows), then the preview appears in the MFC frame window. This is because Visual C++ 4.2b called GetParent instead of GetParentFrame. The problem was corrected in VC 5.0. To get back the old behavior you have to modify the MFC sources and rebuild the MFC libraries. It is not possible to override DoPrintPreview in your CView derived class since it requires the use of protected members of friend classes. Rebuilding the MFC libraries is not supported. (c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Adam Kim, Microsoft Corporation |
Keywords : kbprg kbui MfcDocView MfcPrinting MfcUI kbfasttip
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |