Introduction to the Printer Compatibility Library
The Visual Basic Printer Compatibility library enables code that uses the Visual Basic 6.0 Printer object to run correctly after being upgraded to Visual Basic 2005. In addition, you can subsequently modify upgraded code in Visual Basic 2005 by using the Printer Compatibility library.
Although you can use the Printer Compatibility library for new applications, you should use the Windows Forms PrintDocument component instead. Use the Printer Compatibility library only when compatibility with Visual Basic 6.0 syntax is required.
When a Visual Basic 6.0 application is upgraded, code that references the Printer object is not upgraded and must be rewritten to use .NET Framework printing methods. The Printer Compatibility library solves this problem by using the .NET Framework to re-create the Printer object and Printers collection. This enables your upgraded printing code to run with only minor modifications.
Visual Basic 6.0 had an intrinsic Printer object that you could use without explicitly declaring it. In contrast, the Printer Compatibility library behaves like any other .NET Framework object; you must explicitly declare a .NET Framework Printer object before you can use it.
Instead of rewriting your printing logic to use the event-driven PrintDocument you can simply add a reference to the Printer Compatibility library and a declaration for the Printer object. Doing this eliminates most errors or warnings that are inserted by the Upgrade tool.
Errors that appear in the Error List will be removed. You must manually remove all error or warning comments that appear in the Task List and were inserted into the code, but these comments will not prevent the code from compiling.
The Printer Compatibility library includes most of the properties and methods of the Visual Basic 6.0 Printer object. The DrawMode, DriverName, hDC, Port, TrackDefault, and Zoom properties are no longer supported.
It also includes several new properties and methods that make additional development easier, including a PrintAction property that enables print preview or allows you to print to a file. This enables you to add features or change your printing code without rewriting it to use .NET Framework methods.
The Printer Compatibility Library also includes a PrinterCollection class that provides information about the printers on a system. This global Printers collection exposed by the class can be used to select a specific printer.