17.5.5 Changing the Print Settings Without Affecting Other Applications

Your application can alter the print settings without affecting other applications. To make your application do this, follow these steps:

1.Call ExtDeviceMode, including the following information in the parameters:

Parameter Value

lpdmInput A pointer to the buffer that contains the partial or complete DEVMODE structure you are supplying
lpdmOutput A pointer to the output buffer
fwMode DM_MODIFY | DM_COPY
  or
  DM_PROMPT | DM_COPY
  or
  DM_MODIFY | DM_PROMPT | DM_COPY

Note that you can specify either or both input values (DM_PROMPT and DM_MODIFY). This call to ExtDeviceMode saves a private copy of the print settings in a buffer that your application maintains. Since the call omits the DM_UPDATE output value, the driver does not copy the new print settings to the printer environment and WIN.INI. Therefore, other applications will not be affected by your private print settings.

2.Pass the output DEVMODE structure to CreateDC to create a printer device context that uses the new settings.

Note:

You can save the output DEVMODE structure to a permanent location such as a reserved area in your application's document file. Then, in a later session, your application can read the DEVMODE structure from the document file and pass it directly to CreateDC without having to first call ExtDeviceMode.