Printer Device Contexts (Documents and Printing)
Just as an application requires a display device context (DC) before it can begin drawing in the client area of a window, it needs a printer DC before it can begin sending output to a printer. A printer DC is similar to a display DC in that it is an internal data structure that defines a set of graphic objects and their associated attributes and specifies the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, and a font for text output.
Unlike a display DC, a printer DC is not owned by the window management component, and it cannot be obtained by calling the GetDC function. Instead, an application must call the CreateDC or PrintDlgEx function.
If your application calls the CreateDC function, it must supply a driver and port name. To retrieve these names, call the GetPrinter or EnumPrinters function.
If your application calls the PrintDlgEx function and specifies the PD_RETURNDC value in the Flags member of the PRINTDLGEX structure, the system returns a handle to a device context for the printer selected by the user. For more information, see Print Property Sheet and "Using the Print Property Sheet" in Using Common Dialog Boxes.