Microsoft KB Archive/34917

= PRINT to Viewport Has Screen's Background Color Not Viewport's =

Article ID: 34917

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q34917



SUMMARY
When PRINTing text to a viewport that has a different color than the main screen, the background color of the text will be the same as the background color of the screen, not the viewport. This is expected behavior.

This information applies to Microsoft QuickBasic Versions 4.00 4.00b and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.



MORE INFORMATION
If you have one window on the screen, you can use the following method:
 * 1) Switch to graphics mode.
 * 2) Change the background color to be the color of the window.
 * 3) Paint the screen the actual background color.
 * 4) Draw the window.
 * 5) Print the text.

Note that steps 2 and 3 will cause a flash on the screen. This cannot be avoided. The following is a code sample: SCREEN 9 COLOR 7, 1 VIEW (0, 0)-(639, 349), 2 VIEW (100, 100)-(300, 300), 1 LOCATE 20, 20: PRINT &quot;This is a test&quot; WHILE INKEY$ = &quot;&quot;: WEND The following is a code example of the undesired result: REM This is a sample program that demonstrates printing REM text to a viewport. The background color of the text REM printed to the viewport is the same as that of the REM screens. CLS SCREEN 9 REM Screen has green foreground and light blue background: COLOR 10, 11 REM Set up first viewport with red background: VIEW (10, 10)-(600, 200), 12, 11 REM Print is green with light blue background: LOCATE 1, 11: PRINT &quot;Outer viewport&quot; REM Set up second viewport with purple background: VIEW SCREEN (50, 50)-(350, 150), 5, 7 REM Print is green with light blue background: LOCATE 9, 9: PRINT &quot;Inner viewport&quot; END

Additional query words: QuickBas BasicCom

Keywords: KB34917

-

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

© Microsoft Corporation. All rights reserved.