SetGadgetColor

Just starting out? Need help? Post your questions and find answers here.
RamRat
User
User
Posts: 20
Joined: Mon Nov 14, 2016 9:58 am
Location: Oz

SetGadgetColor

Post by RamRat »

Ok, I want the ListViewGadget to pulse when selecting an item

sooo what's the easiest way to get this to fade to black then back to white? SetGadgetColor(2, #PB_Gadget_FrontColor, $FFFFFF)

Do I chuck it in a quick loop while adjusting the colour? If so how easy is it do put this $FFFFFF in a quick loop?

Cheers!
:shock:
PureLust
Enthusiast
Enthusiast
Posts: 486
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: SetGadgetColor

Post by PureLust »

Maybe this could push you in the right direction. :wink:

Code: Select all

OpenWindow(0,0,0,200,300,"Flashing ...", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ListViewGadget(0,5,5,190,290)
For n = 1 To 37
	AddGadgetItem(0,-1,"Hello, I'm Line number "+Str(n))
Next

Color = 255					; starting from white
stepper = 32				; stepping up/down 32 shades

Repeat
	Event = WaitWindowEvent()
	Select Event
		Case #PB_Event_Timer
			color - stepper
			If color < 0
				color = 255						; set back to white
				RemoveWindowTimer(0,0)		; remove timer
			EndIf
			SetGadgetColor(0,#PB_Gadget_BackColor, RGB(Color, Color, Color))	; set actual color
		Case #PB_Event_Gadget
			If EventGadget() = 0
				If EventType() = #PB_EventType_LeftClick
					AddWindowTimer(0,0,10)	; Change color every 10ms
				EndIf
			EndIf
	EndSelect
Until Event = #PB_Event_CloseWindow
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
RamRat
User
User
Posts: 20
Joined: Mon Nov 14, 2016 9:58 am
Location: Oz

Re: SetGadgetColor

Post by RamRat »

Thanks! Did not realise I could throw RGB in there lol, beats my embarrassing attempt :oops:

Code: Select all

  

        SetGadgetColor(2, #PB_Gadget_FrontColor, $FFFFFF)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $EEEEEE) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $DDDDDD) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $CCCCCC) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $BBBBBB) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $AAAAAA) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $999999) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $888888) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $777777) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $555555) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $333333) : Delay(5)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $111111) : Delay(5)
        
               
        FileName$ = ReplaceString(GetGadgetText(2)," ","%20")
        SetGadgetState(2,-1)
        *buf = ReceiveHTTPMemory("http://www.omdbapi.com/?t=" + FileName$)
        OMDB$ = PeekS(*buf,-1,#PB_Ascii)
        
        
        SetGadgetColor(2, #PB_Gadget_FrontColor, $111111) : Delay(5)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $333333) : Delay(5)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $555555) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $777777) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $999999) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $BBBBBB) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $CCCCCC) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $DDDDDD) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $EEEEEE) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $FFFFFF) : Delay(10)
:shock:
User avatar
mk-soft
Always Here
Always Here
Posts: 6558
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: SetGadgetColor

Post by mk-soft »

Don´t use Delay() with Gadget functions. Always need a Event-Loop for update window...
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Post Reply