BUG: Printer.ForeColor Property Does Not Work Correctly (255115)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q255115 SYMPTOMS
You can use the Printer.ForeColor property to print color text. However, if you set this property before you print anything on a new page, it may have no effect.
CAUSE
This problem stems from the way in which the Visual Basic Printer object calls the underlying API functions, StartPage and EndPage.
-
In Microsoft Windows 95, Windows 98, and Windows Me, the StartPage function call resets the Printer's Device Context attributes to default values and so it is required to set the fore color and re-select objects every time the StartPage function is called.
-
In Microsoft Windows NT and Microsoft Windows 2000, the StartPage function call does not reset the Device Context attributes so that Device Context attributes remain constant across subsequent pages. However, it is required to set the fore color and select objects the first time the StartPage function is called.
-
The Printer object for Visual Basic does not set the fore color automatically after the StartPage function call.
-
The Printer object calls the StartPage function only when the Printer.Print method is called to eliminate unnecessary blank pages. The Printer.NewPage method only calls the EndPage function.
RESOLUTION
To work around the problem, you need to force a call to the StartPage function with the Printer.Print method and then set the Printer.ForeColor property yourself.
You need to do this for the first page only if your application only targets on Windows NT and Windows 2000.
You need to do this for each page if your application is to be delivered to Windows 9x and Windows Me platforms.
NOTE: This workaround requires that you issue the Printer.NewPage function call explicitly by calculating when a new page should be started. If Visual Basic automatically starts a new page for you, you do not have a chance to apply the workaround for Windows 9x.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. REFERENCES
MSDN Platform SDK: StartPage
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbbug kbnofix kbprint KB255115 |
---|
|