17.8 Working with Older Printer Drivers

Printer drivers written for versions of Windows earlier than 3.0 provide only the DeviceMode function, which displays a dialog box from which the user can specify print settings, such as page orientation and paper size. With these printer drivers, changes made to the print settings affect the entire system, not just the calling application.

Like other device-driver functions, the DeviceMode function is part of the driver, not part of GDI. (For an explanation about how to call device-driver functions, see Section 17.2, “Using Device-Driver Functions.”) When you call a driver's DeviceMode function, the driver displays its Printer Setup dialog box, from which the user can change the print settings for that printer and printer port.

The following example shows how to use the function's procedure address, lpfnDeviceMode, to call the DeviceMode function:

if (lpfnDeviceMode != NULL) /* if driver supports this function... */
{
    (*lpfnDeviceMode) ((HWND) hWnd,     /* handle of parent window */
        (HANDLE) hDriver,               /* handle of driver module */
        (LPSTR) "PSCRIPT",              /* printer name            */
        (LPSTR) "LPT1:");               /* port name               */
}