Deletes from memory a bitmap created with Get or the API function CreateDIBSection.
FreeBmp hBmp
hBmp:Handle, integer expression
With Get or the Windows API function CreateDIBSection you can create a bitmap and retrieve its handle. This is a good way to place many pictures in memory. However, once a bitmap is no longer needed, you must free its handle with FreeBmp. Note: Each use of the Get command which returns a handle requires a matching FreeBmp statement to free the memory, otherwise you will get a Memory leak.
However, if the handle produced with Get is then used, through CreatePicture, to create a picture object, FreeBmp should not be used until after you have finished with the picture object; otherwise, it will delete the handle which forms the source of the picture and, thus, the picture will not be shown.
OpenW 1
Global pict%, i%
Ocx Command cmd1 = "Exit", 10, 10, 100, 40
Win_1.AutoClose = False
For i% = 1 To 30
Circle 200, 200, 10 + i% * 2
Color i% * 1000
Next
Get 120, 120, 280, 280, pict%
Line 0, 119, _X, 119
Line 0, 281, _X, 281
Put 300, 120, pict%
Do
Sleep
Until Me Is Nothing
Sub cmd1_Click
PostMessage Win_1.hWnd, WM_CLOSE, 0, 0
EndSub
Sub Win_1_Close(Cancel?)
If Message("Really Quit??", , MB_YESNO) = IDYES
Cancel? = False
FreeBmp(pict%)
EndIf
EndSub
{Created by Sjouke Hamstra; Last updated: 07/10/2014 by James Gaite}