ImageGadget + SetGadgetState

Just starting out? Need help? Post your questions and find answers here.
Vekuuu
New User
New User
Posts: 2
Joined: Sat Apr 06, 2024 10:13 am

ImageGadget + SetGadgetState

Post by Vekuuu »

Hi,
I'm new with PureBasic and I didn't figure out how to use SetImageState.

I want to update 2D draw, I can do it by launching ImageGadget again, but the screen will flicker. I read it is possible to use SetGadgetState to make it update, but I don't know hoe to do it.

It would be nice if some could give a coding sample how to use SetGadgetState with ImageGadget to make it update drawing.

Br & Thanks.
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ImageGadget + SetGadgetState

Post by mk-soft »

Welcome ...

SetGadgetState(Gadget, ImageID(image))
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: ImageGadget + SetGadgetState

Post by infratec »

Code: Select all

EnableExplicit

Define.i Event


LoadImage(0, #PB_Compiler_Home + "Examples\3D\Data\PureBasicLogo.bmp")
LoadImage(1, #PB_Compiler_Home + "Examples\3D\Data\Textures\Geebee2.bmp")

If OpenWindow(0, 0, 0, 400, 200, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ImageGadget(0,  10, 10, 0, 0, ImageID(0))
  ButtonGadget(1, 10, 170, 50, 20, "Change", #PB_Button_Toggle)
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      If EventGadget() = 1
        SetGadgetState(0, ImageID(GetGadgetState(1)))
      EndIf
    EndIf
  Until Event = #PB_Event_CloseWindow
EndIf
Vekuuu
New User
New User
Posts: 2
Joined: Sat Apr 06, 2024 10:13 am

Re: ImageGadget + SetGadgetState

Post by Vekuuu »

Works fine, thank you very much!
Post Reply