BUG: Mac QB Forgets Clip Region When Changing Between Windows (62271)






This article was previously published under Q62271

SYMPTOMS

The QuickBasic MBLC routine SetClip can be used to set the clipping region for the current output WINDOW and GraphPort. However, if a clipping region is set in one WINDOW, and the active window is then changed to a different WINDOW, the clipping region set for the previous WINDOW will be "forgotten." The example below demonstrates this behavior.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

To work around the problem, reset the clipping region whenever you set a WINDOW to be the active WINDOW again. For example, in the code example below, SetClip is used in WINDOW 1. WINDOW 2 is then set to the current WINDOW. Then WINDOW 1 is made the current WINDOW again. When WINDOW 1 becomes the current WINDOW again, SetClip should be used to reset the clipping region.

This following code example demonstrates the problem. To show the workaround, uncomment the line marked as the workaround.

Code Example

ScreenWidth% = SYSTEM(5)
ScreenHeight% = SYSTEM(6)
CenterX% = ScreenWidth% / 2
CenterY% = ScreenHeight% / 2
x1% = CenterX% /4 : x2% = CenterX% - 40
y1% = CenterY% /2 : y2% = CenterY% + 20

WINDOW 2, "window 1",(CenterX%, 20) - (ScreenWidth%,_
           ScreenHeight%), 7
WINDOW 1, "window 1",(20, 20)-(CenterX%,_
           ScreenHeight%), 5

' Set a small, square clipping region
CALL SetClipRegion(x1%, y1%, x2%, y2%)

'Draw lines to show the boundaries of the clip region
'Lines are drawn only within the clip region
FOR n = 1 TO 100
  LINE (1, n * 4)-(ScreenWidth%, n * 4)
NEXT n
' Toggle between the windows.
WINDOW 2
INPUT "HIT RETURN TO CONTINUE", a$
WINDOW 1

'***** Uncomment the following line to show the workaround ****
'  CALL SetClipRegion(x1%, y1%, x2%, y2%)
'**************************************************************
' Draw Circles to show the current clip region
x1% = CenterX% / 2
FOR I = 1 TO 30
  CIRCLE (x1% , CenterY%), I * 5
NEXT I
INPUT "HIT RETURN TO EXIT THE PROGRAM", a$

WINDOW CLOSE 1
WINDOW CLOSE 2

END

SUB SetClipRegion(x1%, y1%, x2%, y2%) STATIC
     R& = 0 : SetRect c%(0), x1%, y1%, x2%, y2%
     NewRgn R& : OpenRgn
     FRAMERECT VARPTR(c%(0))
     CloseRgn R&
     SetClip R&
     DisposeRgn R&
END SUB
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: kbbug KB62271