How to Use CopyBits ToolBox Call in Macintosh QuickBASIC (57381)






This article was previously published under Q57381

SUMMARY

Below is an example of how to use the CopyBits ToolBox routine described on Page 508 of the "Microsoft QuickBASIC for Apple Macintosh: Language Reference" manual for Version 1.00.

This information applies to Microsoft QuickBASIC Version 1.00 for the Apple Macintosh.

MORE INFORMATION

The CopyBits routine description on Pages 508 and 509 is incorrect and does not work properly. In the argument list for the ToolBox trap, the following array arguments should be long integer types with the following descriptions:
   srcBits%() ---->  srcBits&, a pointer to the source bitmap
   dstBits%() ---->  dstBits&, a pointer to the destination bitmap
   srcRect%() ---->  srcRect&, a pointer to the source rectangle
   dstRect%() ---->  dstRect&, a pointer to the destination rectangle
				
You must first invoke the trap call to get the grafPort record for the source and destination windows. The pointers to the bitmaps and rectangles are obtained from these grafPort records. CopyBits can then use this information to copy a bit image between the source and destination windows.

The program shown below uses the ToolBox trap call to get the handle to the grafPort record for the source (src) and destination (dst) grafPorts (windows). GetPort (trap number &HA874) gives the handle for the current, active window. The CopyBits ROM trap is then invoked with the ToolBox statement.

Code Example

GetPort% = &HA874 ' Trap number to grafPort record
CopyBits% = &HA8EC  ' Trap number for the CopyBits routine in ROM
toolbox "i"       ' initialize the toolbox
WINDOW 1,"1",(310,40)-(570,250)
W1GrafPort& = 0   ' initialize variable
toolbox "PQ", GetPort%,W1GrafPort&
WINDOW 2,"2",(40,40)-(300,250)
W2GrafPort& = 0
toolbox "PQ",GetPort%,W2GrafPort&
FOR i = 1 to 150
   LINE (10,i)-(150,i)
NEXT i
WINDOW 1
DestBitMap& = W1GrafPort& + 2  ' get bitmap from grafPort record
                               ' of window 1
SrcBitMap& = W2GrafPort& + 2   ' get bitmap from grafPort Record
                               ' of window 2. This is where we'll
                               ' draw our graphics.
SrcRect& = W1GrafPort& + 16    ' get rectangle from grafPort record
                               ' of window 1
DestRect& = SrcRect&           ' Get rectangle for destination bitmap
hMaskRgn& = PEEKL(W2GrafPort& + 28)
TxMode% = 0                    ' Only copy the source grafPort
' The following two lines must be placed on one physical line:
toolbox "PQ",CopyBits%,(SrcBitMap&),(DestBitMap&),(SrcRect&),
      (DestRect&),(TxMode%),(hMaskRgn&) 'Append this to previous line
WINDOW CLOSE 1
WINDOW CLOSE 2
END
				

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB57381