The print preview behavior in Visual C++ .NET or in Visual C++ 2005 (328698)



The information in this article applies to:

  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

This article was previously published under Q328698

SUMMARY

In Visual C++ .NET or in Visual C++ 2005, print preview always appears in the Multiple-Document Interface (MDI) frame window.

MORE INFORMATION

The following code is from Microsoft Foundation Classes (MFC) source code of Visual C++ .NET or of Visual C++ 2005:
BOOL CView::DoPrintPreview(UINT nIDResource, CView* pPrintView,
   CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState)
   {
       ...
	
	CWnd* pMainWnd = GetParentFrame();
	if (DYNAMIC_DOWNCAST(CFrameWnd, pMainWnd) == NULL)
	{
		// If it is not a frame, try the main window.
		pMainWnd = AfxGetMainWnd();
	}

	CFrameWnd* pParent = STATIC_DOWNCAST(CFrameWnd, pMainWnd);
	ASSERT_VALID(pParent);
				
Note You must add the common language runtime support compiler option (/clr:oldSyntax) in Visual C++ 2005 to successfully compile the previous code sample. To add the common language runtime support compiler option in Visual C++ 2005, follow these steps:
  1. Click Project, and then click <ProjectName> Properties.

    Note <ProjectName> is a placeholder for the name of the project.
  2. Expand Configuration Properties, and then click General.
  3. Click to select Common Language Runtime Support, Old Syntax (/clr:oldSyntax) in the Common Language Runtime support project setting in the right pane, click Apply, and then click OK.
For more information about the common language runtime support compiler option, visit the following Microsoft Web site:

/clr (Common Language Runtime Compilation)
http://msdn2.microsoft.com/en-us/library/k8d11d4s.aspx

REFERENCES


Modification Type:MajorLast Reviewed:1/5/2006
Keywords:kbinfo kbprint KB328698 kbAudDeveloper