17.5.3 Changing the Print Settings

Often, when printing, your application may have to change the print settings to suit its own printing requirements. To change the print settings, set the fwMode parameter of ExtDeviceMode to both an input value (DM_MODIFY or DM_PROMPT) and an output value (DM_COPY or DM_UPDATE). You can specify multiple values, as long as you use at least one input and one output value. (To change the settings without affecting other applications, do not specify the DM_UPDATE output value; that value causes the driver to change the default print settings to those you specify.)

There are several different ways to provide new print settings as input. For each method, you set fwMode to a different combination of values. The input methods are as follows:

Provide a partial DEVMODE structure with the new settings you want. (When calling ExtDeviceMode, specify the value DM_MODIFY.)

Display the driver's Printer Setup dialog box so that the user can change the settings. (When calling ExtDeviceMode, specify the value DM_PROMPT.)

Provide a partial DEVMODE structure and, in addition, display the driver's Printer Setup dialog box. This method lets both your application and the user change the settings. (When calling ExtDeviceMode, specify both the DM_MODIFY and DM_PROMPT values.)

When changing the print settings, you not only provide new print settings as input, you also specify where you want the driver to place the updated print settings. The driver provides as output a complete, valid DEVMODE structure that reflects the changes your application or the user (or both) has just made to the print settings. Your instructions tell the driver where to put this output structure. You determine the driver's output by specifying one or more output values for the fwMode parameter of the ExtDeviceMode function.

You can direct the driver to do one of the following:

Place the updated DEVMODE structure in the output buffer. Your application can then pass this output structure to CreateDC and other Windows functions. (When calling ExtDeviceMode, specify the value DM_COPY in fwMode.)

Write the updated DEVMODE structure to memory. When the printer driver does this, it resets the printer environment for that printer port and changes the relevant entries in WIN.INI. The new settings affect any application that uses that port and does not provide its own print settings. (When calling ExtDeviceMode, specify the value DM_UPDATE in fwMode.)

Place the updated DEVMODE structure in the output buffer, reset the printer environment, and update WIN.INI. (When calling ExtDeviceMode, specify both the DM_COPY and DM_UPDATE values in fwMode.)