Default Printing Support for SDI/MDI 

Submitted by date of submission user level 

Mahesh Chand Nov 24, 2000 Beginner 

This article explains how to use default printing support in your SDI/MDI applications using AppWizard.

MFC framework provides default print and print view supports to both SDI and MDI applications. If your application is SDI or MDI then you don't have to write even a single line of code to support print and print preview.

Printing Support for SDI/MDI using AppWizard

My mcPrint application will draw a circle and some text and we will test default printing options. After testing this application, I will explain how MFC framework prints under the hood.

1. Create a MFC exe application

2. Select SDI and leave all default setting for rest of the pages of MFC AppWizard.

3. Goto ClassView and expand CmcPaintView and double click on OnDraw() function and write this one line code 

void CMcPrintView::OnDraw(CDC* pDC)

{

CMcPrintDoc* pDoc = GetDocument();

ASSERT_VALID(pDoc);

// TODO: add draw code for native data here

CRect rect (60, 50, 200, 200);

pDC->Ellipse( 20, 20, 250, 250 );

pDC->DrawText( " mc Test Ellipse ", &rect , DT_PATH_ELLIPSIS );

}

4. Build and run your exe. Here is the result.

Use Print menu to print this output.