BUG: DragGrayRgn Works Differently in QuickBasic

This article was previously published under Q40140
This article has been archived. It is offered "as is" and will no longer be updated.
The program example shown below demonstrates how to work around aproblem with the DragGrayRgn routine in QuickBasic Version 1.00 forMacintosh. The behavior of DragGrayRgn differs from the DragGrayRgnprovided in Basic Version 3.00 or in the earlier Basic CompilerVersion 1.00 for Macintosh.

Microsoft has confirmed this DragGrayRgn problem in QuickBasic Version1.00. We are researching this problem and will post new information asit becomes available.
The DragGrayRgn routine (which is an MBLC routine) in QuickBasicproduces 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 aBasic Version 3.00 routine to work around the problem. The program thenbehaves 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 theoriginal region to a new region before the drag, and invokeDragGrayRgn with the new region.

The program example that follows shows a Basic Version 3.00 sourcecode that uses DragGrayRgn which has been modified to make it rununder 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 QuickBasicWINDOW 1,,(10,30)-(500,300),2OPTION BASE 1bool% = 0FirstReg& = 0   QBReg& =0               ' Required only for QuickBasicDIM bnd%(4), pin%(4), p%(2), dis%(2)SetRect bnd%(1), 0, 0, 490, 270SetRect pin%(1), 0, 0, 490, 270NewRgn FirstReg& : OpenRgnMOVETO 50, 39 : LINETO 60, 21LINETO 70, 39 : LINETO 51, 39CloseRgn FirstReg&PaintRgn FirstReg&  NewRgn QBReg&                  ' Required only for QuickBasic  CopyRgn FirstReg&, QBReg&      ' Required only for QuickBasicWaitClick:WHILE MOUSE(0) <> 0 : WENDWHILE MOUSE(0) = 0 : WENDGetMouse 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:

  1. For this program to run in Basic Version 3.00, you must change the following:

    1. Change all "&" characters to "!" (because Basic Version 3.00 doesn't support the long-integer data type).
    2. Remove all lines that are marked "Required for QuickBasic".
    3. Change the DragGrayRgn routine to use FirstReg instead of QBReg.
    4. 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".)
  2. 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.

Article ID: 40140 - Last Review: 02/27/2014 20:59:22 - Revision: 1.2

  • kbnosurvey kbarchive kbbug KB40140