DOCERR: Suggested Changes to the DEVCAPS2 Sample AppLast reviewed: January 9, 1996Article ID: Q80784 |
The information in this article applies to:
SUMMARYDEVCAPS2 is a sample application developed for the Windows environment by Charles Petzold. DEVCAPS2 demonstrates how to retrieve various capabilities of a printer or display device. This sample is included in the book "Programming Windows Version 3," published by Microsoft Press. This article describes a change that should be made to the code in DEVCAPS2, and also to any application based on DEVCAPS2. This change works around a problem in calling the DeviceMode() API.
MORE INFORMATION
Problem DescriptionWhen the user selects DeviceMode from the File menu and modifies the printer settings in the dialog box, the unmodified version of DEVCAPS2 does not update the WIN.INI file with the changed information. Similarly, any changes to printer settings made using the Control Panel are not reflected in the dialog box in DEVCAPS2. The DeviceMode menu item is designed to allow the user to modify any printer settings globally, for all applications. Any application that uses the DeviceMode dialog box should use the new printer settings. In addition, the application should write the new printer settings into the WIN.INI file.
ResolutionBecause the DEVCAPS2 program calls the DeviceMode() API with incorrect parameters, it exhibits the behavior described above. The following code appears in the DEVCAPS2.C file starting at line 176:
szOutput = strtok(szDriver,", "); strcat(strcpy(szDriverFile, szDriver), ".DRV");The code above sets szOutput equal to the name of the device driver (for example, "EPSON9") rather than to the output port (for example, "LPT1:"). To correct this problem, modify the code to add an additional call to the strtok function, as in the following code:
szOutput = strtok(szDriver, ", "); szOutput = strtok(NULL, ", "); strcat(strcpy(szDriverFile, szDriver), ".DRV");After the modification, szOutput points to the output port. In the subsequent call to DeviceMode(), the parameters are correct, and the function works as expected. In Windows version 3.1, applications should call ExtDeviceMode() instead of DeviceMode().
|
Additional reference words: 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |