CPrintDialog::GetPrinterDC

Retrieves a handle to the printer device context.

HDC GetPrinterDC( ) const;

Return Value

A handle to the printer device context if successful; otherwise NULL.

Remarks

If the bPrintSetupOnly parameter of the CPrintDialog constructor was FALSE (indicating that the Print dialog box is displayed), then GetPrinterDC returns a handle to the printer device context. You must call the Windows DeleteDC function to delete the device context when you are done using it.

Example

CPrintDialog dlg(FALSE);
if (dlg.DoModal() == IDOK)
{
   // Get a handle to the printer device context (DC).
   HDC hdc = dlg.GetPrinterDC();
   ASSERT(hdc);

   // Do something with the HDC...

   // Clean up.
   CDC::FromHandle(hdc)->DeleteDC();
}

Requirements

Header: afxdlgs.h

See Also

Reference

CPrintDialog Class

Hierarchy Chart

Other Resources

CPrintDialog Members