Diagnosing Printing Problems in Your ApplicationLast reviewed: August 8, 1996Article ID: Q101413 |
The information in this article applies to:
SUMMARYWhen you are in the midst of development and concentrating on coding, it is easy to lose sight of problem areas external to your application. When diagnosing a printing problem in your application, there are three major areas to be aware of:
MORE INFORMATION
Environment/Network IssuesCheck List:
Do other Windows-based applications such as Paintbrush or Microsoft Write print successfully? If they do not, then the problem probably isn't with your application. You should try a clean boot (starting your computer after all unnecessary commands have been removed from your CONFIG.SYS and AUTOEXEC.BAT files) to help narrow down the problem. Try printing to a local printer to ensure that the problem isn't related to your network. If your application prints correctly to a local printer and not to the network printer, the problem could be with incorrect network settings. Is Print Manager enabled? If not, try enabling Print Manager. Try turning off the Fast Printing Direct To Port option if it's on. For more information about how these settings affect printing in Windows, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q82746 TITLE : General Information About Print Manager and Windows 3.1 ARTICLE-ID: Q82747 TITLE : How Windows Prints to a NetworkMake sure there's enough disk space for the temp files that are created during printing. If the TEMP environment variable points to a network drive, make sure it has the correct permissions set on it.
Printer and Driver IssuesCheck List:
It is important to test with several different printers to determine whether the problem happens only on a specific printer. If so, be sure to check the WDL to determine whether there's an updated driver for the printer. Be sure to test printing on machines with different display drivers. Printer drivers normally do not support all output functions and rely on GDI to assist. In many cases, GDI in turn calls into the display driver to do the actual work. So, a bug in the display driver could show up during printing. For example, test with the standard VGA driver that shipped with Windows 3.1 and another display driver with more capabilities such as the 8514/a. Check for incorrect settings on the printer. Make sure the printer is set up correctly in Print Manager. Check that the correct properties, printer port, and so on, have been specified. It's possible the printer driver file is corrupt. Try removing the printer driver through Control Panel, deleting the printer driver file (along with deleting UNIDRIV.DLL if appropriate) and reinstalling the driver through Control Panel.
Application Coding IssuesCheck List:
Do the Windows Software Development Kit (SDK) sample programs PRNTFILE and DIBVIEW print correctly on your system? If so, comparing your code to these samples will be useful. Note that there is a minor bug in PRNTFILE. To fix it, move to where the bAbort flag in PRNTFILE.C is initialized to right after the IDM_PRINT case, before any calls to escape. Without this fix, with some printers, if you begin printing, cancel, and try to print again, you will receive an error on the STARTDOC escape. This is because some printer drivers call your application's abort procedure during STARTDOC, and the bAbort flag has not been reinitialized after canceling the previous print job. Do you do banding (using the NEXTBAND and BANDINFO escapes) in your application? This is particularly important if you are doing a lot of graphics output or you are making calls to the SDK region functions. There have been problem reports concerning the region functions consuming GDI resources in nonbanding applications, and at this time the only known resolution is to implement banding in your application. If you don't do banding in your application then Windows does it for you by creating a disk-based metafile and then playing back the entire metafile into each printer band. Using the NEXTBAND escape eliminates the disk-based metafile so the printing process is greatly simplified. As an added benefit, you should notice an increase in performance. After adding the NEXTBAND escape, try optimizing your code even more using the BANDINFO escape. The sample program DIBVIEW demonstrates the correct usage of both the NEXTBAND and BANDINFO escapes. If you need more information on banding, query on the following word in the Microsoft Knowledge Base:
GdiPrnBandingThe Microsoft Developer Network (MSDN) CD article "Printing" is a must read for anyone implementing printing under Windows. Keep in mind that the article was written around the time Windows 3.1 was released when the problems with the Windows banding/metafile code were not known. Because of this, the article does not emphasize the importance of implementing banding in your application. If you are just learning about printing under Windows, or if you are considering implementing banding in your application, the Printing Self-Study Module has a great deal of information and sample code ready for your use. For more information about the Printing Self-Study Module, see the following application note in the Microsoft Knowledge Base:
Appnote: PW0778: Printing Self-Study ModuleHere's a few other ideas:
|
Additional reference words: 3.10 appnote
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |