- SetGadgetState(): Change the current Image of the gadget. A valid ImageID can be easily obtained with the UseImage() or ImageID() commands. If the ImageID is 0, then the image is removed from the gadget.
But if I have an image currently displayed in a ImageGadget (#Image_0) from whatever source (it doesn't matter), and I try:
It does not remove the currently displayed image from the gadget at all, as it states in the manual. Instead nothing happens and the image is left intact and displayed, as before.
Why doesn't specifying zero as the ImageID remove the image from the gadget, as the manual states it should? Thanks!
If OpenWindow(0,300,200,300,200,"test",#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
pic1=CreateImage(1,50,50) ; Small black square.
pic2=CreateImage(2,100,100) ; Large black square.
ImageGadget(1,20,20,100,100,pic1)
ButtonGadget(2,20,130,130,25,"Click to switch images")
Repeat
ev=WaitWindowEvent()
If ev=#PB_Event_Gadget And EventGadget()=2
count+1
If count=1
SetGadgetState(1,pic2)
SetGadgetText(2,"Click to clear image")
ElseIf count=2
SetGadgetState(1,0)
EndIf
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Hi, thanks for your reply and help with the example. However, when I run that code in PB (after fixing the minor error in the OpenWindow statement that prevented it from running) I can confirm that clicking the button the second time does NOT remove/clear the "large black square" image from the gadget. Instead the image just stays there forever, until the program is terminated.
I am running PB4 on Windows XP (SP2). What am I doing wrong? Does it actually blank out the larger square for you, when you click the button the second time?
Hi.. no I haven't deliberately enabled SmartWindowRefresh, just running PB the default way with no such special command. But even when I deliberately did:
I downloaded the newest image lib, copied-and-pasted it over my old version in PureLibraries, restarted the compiler but no difference. Large black square still isn't cleared with second button click.
nco2k wrote:hm.. try the beta gadget lib aswell, because its a gadget after all. if that doesnt work i really dont know why it doesnt work for you properly.
have you installed pb4 into a new empty folder or over an existing older pb version?
Tried the newest gadget lib but no luck there either. I installed PB4 into a new
empty folder. I still have my older version (3.9x) intact in its old folder.
It's quite a mystery why it isn't working for me, and I guess there's nothing to do about it for the time being. Thank you for the help though really, I do appreciate the attempt.
Okay, I re-installed PB4 completely and now it does in fact seem to work fine. I'm not sure why this was happening, but I think the compiler was still referencing some of my older 3.9x files in the old directory, as evidenced by the fact that the initially posted code produced an old-time error on the OpenWindow statement, wanting the text name of the window to come after the flags, as it used to be in older versions of PB.
Anyway, thanks again to all for the help.. off I go to make some more progress....