Article ID: 133275 - View products that this article applies to.
This article was previously published under Q133275
This article has been archived. It is offered "as is" and will no longer be updated.
The standard method to support printing capability in an MFC application is to override the OnDraw(CDC* pDC) member function of the CView class that provides the pointer to the device context (pDC). If the application does not possess a CView class (for example, a dialog-based application), you can use the code listed in this article to obtain a pointer to the printing device context to implement printing.
In this example, CMyDialog is publicly derived from CDialog, OnPrintBuf() is a message handler that is mapped to BN_CLICKED, and SetPrintAlign() is used to select print settings specified to an application. The sample code prints the contents of the 'pbuf' buffer.
For more information about the MFC printing, please see "Programming with the Microsoft Foundation Class Library" in Books Online.
Article ID: 133275 - Last Review: October 26, 2013 - Revision: 4.0