All printer drivers are required to export the DeviceMode function, which displays a dialog box to edit the default environment. This function sets the profile strings in the WIN.INI file for the options chosen by the user. It should also set the environment using the SetEnvironment function. The DeviceMode function uses USER functions, such as DialogBox (USER.240), to display dialog boxes.
The most common way to call DeviceMode is with Control Panel. However, other applications that make heavy use of printer output, such as Microsoft Write or Microsoft Excel, may also provide a means for calling the printer driver's DeviceMode function.
Windows 3.x drivers also export two environment-related functions, ExtDeviceMode and DeviceCapabilities. These functions are designed to allow greater application control over the printer environment. All printer drivers should implement these functions.
ExtDeviceMode enables the application to call the driver to obtain device initialization data either from the user or from the application's modifications to the default environment. GDI then calls the Enable function with a pointer to this information, allowing the driver to preset its GDIINFO and PDEVICE structures according to the application's options, rather than the defaults. That way, the application can store different printer settings for itself and its documents or even request specific setup properties, such as orientation.
DeviceCapabilities enables the application to get information about such things as what DeviceMode fields the driver uses and what limits, ranges, or selections are valid.
Printer drivers must process requests from applications for new DeviceCapabilities indexes. A driver's DeviceCapabilities function must check for and process the following values.
Value | Meaning |
DC_ENUMRESOLUTIONS (13) | Retrieves a list of resolutions supported by the model. |
DC_FILEDEPENDENCIES (14) | Retrieves a list of filenames which also need to be installed when the driver is installed. |
DC_TRUETYPE (15) | Retrieves the driver's capabilities with regard to printing TrueType fonts. |
DC_PAPERNAMES (16) | Enumerates the actual string describing the paper names. |
DC_ORIENTATION (17) | Retrieves the relationship between Portrait and Landscape orientations in terms of the number of degrees that portrait orientation is to be rotated counterclock-wise to get landscape orientation. |
DC_COPIES (18) | Retrieves the maximum number of copies the device can print. |
The implementation of one or all of the indices is optional. If a driver does not implement a given index, the DeviceCapabilities function should return -1. For more information about the new indices, see the DeviceCapabilities function.
There are 21 new predefined paper sizes. The include file, PRINT.H, contains a complete list of all supported paper sizes. Applications typically call the DeviceCapabilities function to retrieve names and sizes of the supported paper sizes, so printer drivers must be ready to process the following DeviceCapabilities index values:
Value | Meaning |
DC_PAPER | Retrieves the identifiers of the listed paper sizes. |
DC_PAPERNAMES | Retrieves the names of the listed paper sizes. |
DC_PAPERSIZES | Retrieves the width and height of the listed paper sizes. |