Code: Select all
#include <hmg.ch>
Function Main()
PRIVATE hBitmap := 0
LOAD WINDOW Demo2 AS Demo_2
// SET CONTROL Image_1 OF Demo_2 CLIENTEDGE
SET CONTROL Label_3 OF Demo_2 CLIENTEDGE
SET CONTROL Label_5 OF Demo_2 CLIENTEDGE
SET CONTROL Label_7 OF Demo_2 CLIENTEDGE
SET CONTROL Label_8 OF Demo_2 CLIENTEDGE
ON KEY ESCAPE OF Demo_2 ACTION ThisWindow.Release
Demo_2.Center
/*
IfNotFoundImg("Demo_2","Image_1",{255,153,153})
IfNotFoundImg("Demo_2","Image_2",CYAN)
IfNotFoundImg("Demo_2","Image_3",GREEN)
IfNotFoundImg("Demo_2","Image_4",YELLOW)
*/
Demo_2.Activate
Return Nil
Function IfNotFoundImg(cFormName,cControlName,aRGBcolor_Fill_Bk)
LOCAL i := GetControlIndex ( cControlName, cFormName )
LOCAL nWidth := _HMG_SYSDATA [ 31 ] [i]
LOCAL nHeight := _HMG_SYSDATA [ 32 ] [i]
LOCAL cImgFile := _HMG_SYSDATA [ 25 ] [i]
LOCAL hDC, BTstruct
hBitmap := BT_HMGGetImage (cFormName, cControlName)
If !File(cImgFile) .AND. hBitmap = 0
hBitmap := BT_BitmapCreateNew (nWidth, nHeight, aRGBcolor_Fill_Bk)
hDC := BT_CreateDC (hBitmap, BT_HDC_BITMAP, @BTstruct)
BT_DrawRectangle (hDC, 0, 0, nWidth-1, nHeight-1, BLACK, 1)
BT_DrawLine (hDC, 0, 0, nHeight, nWidth, BLACK, 1)
BT_DrawLine (hDC, nHeight, 0, 0, nWidth, BLACK, 1)
BT_DeleteDC (BTstruct)
BT_HMGSetImage (cFormName, cControlName, hBitmap, .T.)
Endif
Return Nil
Function Proc_ON_RELEASE
BT_BitmapRelease (hBitmap) // Very important
Return Nil
Function Submit(cFileName)
SetNewImage("Image_1","HMG")
SetNewImage("Image_2","PAUL")
SetNewImage("Image_3","AVAILABLE")
SetNewImage("Image_4","PRODUCT")
Return Nil
Function SetNewImage(cControl, cFileName)
LOCAL hBitmap_aux := 0
LOCAL cForm := "Demo_2"
LOCAL w := GetProperty(cForm,cControl,"Width")
LOCAL h := GetProperty(cForm,cControl,"Height")
hBitmap_aux := BT_BitmapLoadFile (cFileName)
hBitmap := BT_BitmapCopyAndResize (hBitmap_aux, w, h, NIL, BT_RESIZE_HALFTONE)
BT_BitmapRelease (hBitmap_aux)
BT_HMGSetImage (cForm, cControl, hBitmap, .F.)
Return Nil
PROC DrawEmpty()
IfNotFoundImg("Demo_2","Image_1",{255,153,153})
IfNotFoundImg("Demo_2","Image_2",CYAN)
IfNotFoundImg("Demo_2","Image_3",GREEN)
IfNotFoundImg("Demo_2","Image_4",YELLOW)
RETU // DrawEmpty()