PDA

View Full Version : LoadImage



catventure
08-11-2006, 18:59
Eros,

In the "Samplescripts\UI\LoadImage\LoadImage.tbasic" code you show how to load a .bmp onto a LABEL control...

What would be the correct procedure to REMOVE the bitmap from the control without deleting the control or hiding the control?
Thanks.

I've tried control set color, that didn't work. I imagine it will be a control send instruction but not sure - something like the one used in the LoadImage example:

CONTROL SEND hDlg, 1001, %STM_SETIMAGE, %IMAGE_BITMAP, hImg

I found I can successfully load different bitmaps onto the control and if necessary could load a "blank" black-colored bitmap onto it to simulate a deletion - but rather than do that I'd prefer to simply delete/remove the bitmap from the label control if possible.

Regards,
catventure.

Petr Schreiber
08-11-2006, 19:40
Hi,

just quick shot, don't know if legal.
Try to pass zero instead of hImg, this will make LABEL look to disappear.
Hope this not GPFs ( on WinME not ).

But I'm sure there is cleaner way, I'm searching...


Petr

catventure
09-11-2006, 01:00
I have found this works, Petr
By sending an empty filename "" and keeping the hImg param I can do a DIALOG REDRAW to clear the bitmap from the label control.
That works :)

I cannot however then do a control set color/control redraw ro color the control... maybe because label equate is %ss_bitmap...?


hImg = LoadImage ( %NULL, "", %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hwnd,%id_picbox1 , %STM_SETIMAGE, %IMAGE_BITMAP,hImg
dialog redraw hwnd
'---this works to clear the bitmap


Best wishes,
catventure

RobertoBianchi
09-11-2006, 09:42
Windows relaase the memory used by a graphical object with the call DeleteObject(), DestroyCursor() and DestroyIcon() API.
I don't remeber if a wrapper of the DeleteObject() API is available, but you can try to declare them and use it passing a hImg.

Regards,
Roberto

catventure
09-11-2006, 14:25
Thanks Roberto,

Not sure what you mean or how to do that..
Anyway I can remove the bitmap as in my example. I am of course using DeleteObject(hImg) when the program is ended to clear memory...

But what I need to know now is if I load successive images onto the same control does the memory build up with each new image displayed? or have I to use deleteobject(hImg) each time to free memory before each picture shown??

Thanks.
catventure.

RobertoBianchi
09-11-2006, 16:28
Catventure,

every time you load a graphic object with LoadImage() API you got one differet handle unless you specify %LR_SHARED as fuLoad parameter (not your case because as I see, you use %LR_LOADFROMFILE).
Different handle means different memory allocation for the object, so my suggestion is use DeleteObject() each time if you finished to use the image.

Ciao,
Roberto

catventure
10-11-2006, 11:25
Hi Roberto,

OK. I understand it now.
Before I was using same handle for 3 different graphic slots when using the LoadImage function...

Now I use different handle for each slot and do a 'deleteobject()' before each new image is shown.
+ a deleteobject() for each handle when program exited.

I'm happy about that now!

Thanks,
catventure

RobertoBianchi
10-11-2006, 17:47
Hi catventure,

I'm not sure that
+ a DeleteObject() for each handle when program exited.
are necessary, but however if the handle is invalid (I mean already released) it would succeed nothing than receive zero from DeleteObject().

Ciao,
Roberto