Microsoft KB Archive/154170

= BUG: @...SAY Prints Gray Background =

Article ID: 154170

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft FoxPro 2.6a Standard Edition

-



This article was previously published under Q154170



SYMPTOMS
It is possible that @...SAYs print with a gray or dark-shaded background when printed from Windows 95 or Windows NT 4.0 using either Microsoft Visual FoxPro for Windows or FoxPro for Windows 2.6. You may experience this problem with all versions of Windows. However, it appears more frequently under Windows 95 and Windows NT 4.0.



CAUSE
There are several reasons why @...SAYs may print a shaded background. One reason may be that the window color is set to a color other than white in the Windows 95 or Windows NT 4.0 Display Properties. In Microsoft Visual FoxPro and FoxPro for Windows 2.6, the background color of the desktop will affect the @...SAYs used in programs. Also, if the @...SAY code is executed from a form in Microsoft Visual FoxPro or a screen in Microsoft FoxPro for Windows 2.6, the background color of these objects will affect printout



RESOLUTION
To change the background color of all windows under Windows 95 or Windows NT 4.0, you must change the Window color on the Appearance tab of the Display Properties. To change this property, right-click the Windows 95 or Windows NT 4.0 desktop, and then click Properties. Click the Appearance tab, click Window under the Item drop-down list, and then click white.

This option may not be desirable because users must keep the window color white whenever they print in @..SAYs from FoxPro under Windows 95 or Windows NT 4.0. A better way to implement this is to check the background color of the window or desktop from the code, the form, or the screen before you issue the @...SAY. To implement this with Microsoft Visual FoxPro 3.0 and Microsoft FoxPro for Windows 2.6., follow these steps:

If the @...SAY code is executed from a program in Visual FoxPro for Windows, the window color can be changed with the following code: IF _Screen.BackColor != 16777215   &&Is color value white? _Screen.LockScreen = .T.        &&Keep screen from flashing cOldbackcolor = _Screen.BackColor     &&Save background color cOldForecolor = _Screen.ForeColor&& Save foreground color _Screen.ForeColor = Rgb(0,0,0) &&Set ForeColor to RGB Black - _Screen.BackColor = RGB(255,255,255) &&Set BackColor to RGB white SET DEVICE TO PRINTER @1,1 say 'This is a test.' SET DEVICE TO SCREEN SET PRINTER TO      _Screen.BackColor = cOldbackcolor _Screen.ForeColor = cOldForecolor _Screen.LockScreen = .F. ENDIF If the @...SAY code is executed from a form in Visual FoxPro for Windows, the background color of the form can be modified with the following code: IF ThisForm.BackColor != 16777215 ThisForm.LockScreen = .T.       SET DEVICE TO PRINTER cOldbackcolor = ThisForm.BackColor cOldForecolor = ThisForm.ForeColor ThisForm.BackColor = RGB(255,255,255) ThisForm.ForeColor = RGB(0,0,0) @1,1 SAY 'This is a test' SET DEVICE TO SCREEN SET PRINTER TO       ThisForm.BackColor = cOldbackcolor ThisForm.ForeColor = cOldForecolor ThisForm.LockScreen = .F. ENDIF NOTE: This code may be placed in the Click event of a Command button.

In FoxPro for Windows 2.6, use the following code to change the window color: cOldscheme = SET('Color of Scheme 1')       &&Obtain old color MODIFY WINDOW SCREEN COLOR RGB(0,0,0,255,255,255) &&Set color white SET DEVICE TO PRINTER @1,1 say ' This is a test.' SET DEVICE TO SCREEN SET PRINTER TO  MODIFY WINDOW SCREEN COLOR &cOldscheme NOTE: In FoxPro 2.6a for Windows, issue the following command after the SET DEVICE TO PRINTER command to prevent the gray background: SET PRINT FONT "some font name", 10



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
If the @...SAY code is executed from Visual FoxPro for Windows with Windows 95 or Windows NT 4.0 as the operating system, all printed pages will be shaded.

Using FoxPro for Windows 2.6 and Windows 95 or Windows NT 4.0, only the first page is shaded. All others print as you expect.

Steps to Reproduce the Behavior
 In Windows 95 or Windows NT 4.0, right-click the desktop, and then click Properties. Click the Appearance tab, and then click Window on the Item drop-down list. Click the Color drop-down list, and then change the color to gray or any color other than white.  Open Visual FoxPro for Windows or FoxPro for Windows 2.6, and then create a program with the following code: SET DEVICE TO PRINTER FOR i = 1 TO 2      &&Loop shows different output from VFP &FPW26 @1,1 SAY 'This is a printing test' FONT 'Arial',14 @3,1 SAY 'From '+VERSION + ' under ' + OS(1) FONT 'Courier New' ENDFOR SET DEVICE TO SCREEN SET PRINTER TO NOTE: This code can be executed in a FoxPro for Windows 2.6 screen, and in a Visual FoxPro for Windows 3.0 form. 

Additional query words: kbvfp300 kbvfp500 kbvfp600

Keywords: kbbug kbprint kbprb KB154170

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.