Microsoft KB Archive/40140
Article ID: 40140
Article Last Modified on 11/21/2006
This article was previously published under Q40140
The program example shown below demonstrates how to work around a problem with the DragGrayRgn routine in QuickBasic Version 1.00 for Macintosh. The behavior of DragGrayRgn differs from the DragGrayRgn provided in Basic Version 3.00 or in the earlier Basic Compiler Version 1.00 for Macintosh.
Microsoft has confirmed this DragGrayRgn problem in QuickBasic Version 1.00. We are researching this problem and will post new information as it becomes available.
The DragGrayRgn routine (which is an MBLC routine) in QuickBasic produces the following incorrect behavior:
DragGrayRgn copies the region into a frame (a border outline), forgets the handle to the original region (so that EraseRgn can't reference or erase it), and leaves you with just a frame outline (at the wrong coordinates) when you finish the drag.
The code example below demonstrates the necessary modifications to a Basic Version 3.00 routine to work around the problem. The program then behaves correctly as follows:
You click on the triangle, drag its outline to a new location, then release the button. At this time, the old triangle should be erased and the outline of the triangle that was dragged to the new location should be filled in.
To work around the problem in QuickBasic Version 1.00, copy the original region to a new region before the drag, and invoke DragGrayRgn with the new region.
The program example that follows shows a Basic Version 3.00 source code that uses DragGrayRgn which has been modified to make it run under QuickBasic Version 1.00:
'This example program is based on one published in Nibble Mac, 'Volume 3, Number 1, 1988, Page 59, Listing 2, DragGrayRgn Example. 'The example is shown modified to run in QuickBasic. REM LIBRARY "ToolLib" 'Required for Basic 3.0, not for QuickBasic WINDOW 1,,(10,30)-(500,300),2 OPTION BASE 1 bool% = 0 FirstReg& = 0 QBReg& =0 ' Required only for QuickBasic DIM bnd%(4), pin%(4), p%(2), dis%(2) SetRect bnd%(1), 0, 0, 490, 270 SetRect pin%(1), 0, 0, 490, 270 NewRgn FirstReg& : OpenRgn MOVETO 50, 39 : LINETO 60, 21 LINETO 70, 39 : LINETO 51, 39 CloseRgn FirstReg& PaintRgn FirstReg& NewRgn QBReg& ' Required only for QuickBasic CopyRgn FirstReg&, QBReg& ' Required only for QuickBasic WaitClick: WHILE MOUSE(0) <> 0 : WEND WHILE MOUSE(0) = 0 : WEND GetMouse p%(1) PtInRgn p%(1), FirstReg&, bool% IF NOT bool% THEN DisposeRgn FirstReg& : STOP ' On the following line, QuickBasic uses QBReg& (instead of ' FirstReg& used in Basic 3.00): DragGrayRgn QBReg&, p%(1), pin%(1), bnd%(1), 0, dis%(1) EraseRgn FirstReg& OffsetRgn FirstReg&, dis%(2), dis%(1) PaintRgn FirstReg& GOTO WaitClick
Note the following:
- For this program to run in Basic Version 3.00, you must change the following:
- Change all "&" characters to "!" (because Basic Version 3.00 doesn't support the long-integer data type).
- Remove all lines that are marked "Required for QuickBasic".
- Change the DragGrayRgn routine to use FirstReg instead of QBReg.
- The first line of the original program example in Nibble Mac referred to LIBRARY "DragGrayLib". You can use "ToolLib" more easily than "DragGrayLib". ("DragGrayLib" is a library file that you must build from CODE resources taken from the "ToolLib" file in Basic Version 3.00. In Basic Version 3.00, you can use Statement Mover to move needed routines from "ToolLib" into "DragGrayLib", if you want a library smaller than "ToolLib".)
- The original DragGrayRgn routine in the Basic Version 3.00 ToolLib correctly remembers the region before the region is dragged with the mouse. The DragGrayRgn routine in QuickBasic requires the workaround solution shown.
Additional query words: MQuickB
Keywords: kbbug KB40140