1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
CDC dc;
CPrintDialog printDlg(FALSE);
// selection de l'imprimante.
if (printDlg.DoModal() == IDCANCEL) return;
dc.Attach(printDlg.GetPrinterDC());
dc.m_bPrinting = TRUE; // dc d'impression.
// titre du document = titre application
CString strTitle;
strTitle.LoadString(AFX_IDS_APP_TITLE);
DOCINFO di;
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle;
// debut d'impression
if(dc.StartDoc( &di ))
{
// debut page
dc.StartPage();
// surface d'impression
CRect rectDraw;
rectDraw.SetRect(0, 0,
dc.GetDeviceCaps(HORZRES),
dc.GetDeviceCaps(VERTRES));
MyOcx.print(&dc, dwFlags) ;
dc.EndPage(); // fin de page
dc.EndDoc(); // fin du document
}
else dc.AbortDoc(); // erreur d'impression
dc.Detach(); // liberation dc d'impression. |