Normally I use the following method -
CPrintDialog dlgPrint(FALSE);
CDC dc; //for the printer
HDC hDC;
// attach the printer dc
hDC = dlgPrint.m_pd.hDC;
dc.Attach(hDC);
//Do whatever printing here
dc.Detach(); //Finished printing - detach the printer DC
Quote:
>We have developed an application which is not using the
>MFC Doc/View architecture. Our main window is a dialog
>which is used to control different analysis algorithms and
>display the results in special designed graphic windows
>(which are running in different threads).
>Our problem is the printing of the graphic windows. We just
>want to create a printer-DC for the default printer. The MFC
>(VC5) documentation is not the best information-base and so
>i'am not sure if our solution is right.
>Our solution:
>// create the printer DC
>CPrintDialog pd(FALSE);
>pd.GetDefaults();
>HDC hDC = pd.GetPrinterDC();
>CDC *pDC = CDC::FromHandle(hDC);
>..... print the graphics window
>// release the printer DC
>::DeleteDC(hDC);
>::GlobalFree(pd.m_pd.hDevMode);
>::GlobalFree(pd.m_pd.hDevNames);
>::GlobalFree(pd.m_pd.hDC);
>// done
>Is this code ok. Please send answers directly to me
>Thank you
-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/ The website for
Visual C++ programmers.