Article ID: 162609
Article Last Modified on 11/21/2006
// Instantiate a CPrintDialog object.
CPrintDialog dlg(FALSE);
// Retrieve the current printer defaults from the Windows .ini file
// as necessary, or uses the last printer configuration set by the
// user in Print Setup.
CWinApp* app = AfxGetApp();
if (!app->GetPrinterDeviceDefaults(&dlg.m_pd))
{
// Fails to create a printer device context for printing because
// no printer is being installed. Bring up dialog box to alert the
// users that they need to install a printer. This step is optional.
if (app->DoPrintDialog(&dlg) != IDOK)
return ;
}
// Creates a printer DC from the DEVMODE and DEVNAMES structures.
if (dlg.CreatePrinterDC() == NULL)
return ;
// A printer device context (DC) has been created.
// Attach it to a CDC object. The DC is deleted when the CDC
// object goes out of scope.
CDC PrintDC;
PrintDC.Attach(dlg.m_pd.hDC);
// ADD YOUR CODE HERE.
Additional query words: 2.00 2.10 2.20 4.00 4.10 4.20 1.50 1.51 1.00 2.50 2.51 2.52 3.00 3.10 3.20 kbdse m_fc vc5rel
Keywords: kbcode kbhowto kbprint KB162609