Microsoft KB Archive/43022

From BetaArchive Wiki
Knowledge Base

Article ID: 43022

Article Last Modified on 11/21/2006

This article was previously published under Q43022


You can draw pictures and save them into the resource fork of a file using the built-in MBLC toolbox routines in QuickBASIC. Once they are saved in the resource fork of a file, you can access them from that file or you can use ResEdit to move them to the resource fork of another file or application.

There are two different ways to write a picture to the resource fork of a file: AddPicture and SavePicture.

This article describes how to record a bitmap picture using OpenPicture and ClosePicture, and to use AddPicture to store the bitmap picture as a PICT resource in a resource file. This type of picture can be viewed in ResEdit. This picture can be loaded back into memory using GetPicture, and redrawn with DrawPicture.

The alternate method is to use SavePicture to save an image that was recorded in the QuickDraw string format with the PICTURE ON and PICTURE OFF statements, as described in another article, which can be found by querying on the following words:

SavePicture Picture QuickBASIC


Code Example

'  Example of how to save a bitmap picture to the
'  resource fork of a file
DIM rec%(3)   ' array to hold coordinates of picture borders
ref% = 0      ' resource-file reference number
handle& = 0   ' handle& is a long-integer handle for the picture
id% = 0       ' identification number of picture in resource file

'  Open an external file called "circle" to hold your resource:
OpenResFile "circle",ref%

'  Record your picture using OpenPicture and ClosePicture routines:
setrect rec%(0),0,0,200,200
OpenPicture rec%(0),handle&     ' Turns on recording of bit-map
CALL SHOWPEN   ' Lets you see picture on the screen as it is recorded
CIRCLE (100,100),25   ' Draws something
ClosePicture    ' Turns off recording of bit-map

'  Place the finished picture in the resource fork of the file:
AddPicture ref%,handle&,id%,"PICT"
CloseResFile ref%

Programming Notes

The following are all MBLC routines stored in QuickBASIC: Setrect, OpenPicture, ClosePicture, OpenResFile, AddPicture, GetPicture, DrawPicture, and CloseResFile.

Additional query words: MQuickB

Keywords: KB43022