Time Spin Gadget
Posted: Sun Aug 17, 2003 11:07 pm
Code updated for 5.20+
I needed a way to input the time using a spin gadget, so here it is in case it is of use to anyone else. Oh and sorry for the bad programing but I'm kinda new to this.
Hope it helps.
Nessie
I needed a way to input the time using a spin gadget, so here it is in case it is of use to anyone else. Oh and sorry for the bad programing but I'm kinda new to this.
Code: Select all
;**********************************
; Time Spin Gadget
; By Garry Watson aka Nessie
; 17/08/03
; Use as you please
;**********************************
FontID1 = LoadFont(1, "Arial", 12, #PB_Font_Bold)
min = 0
spin = 1
hours = 2
sepa = 3
mins = 4
hr=12:hr$="12"
hWnd = OpenWindow(0,0,0,100,100,"TIME",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
If hwnd=0 :End:EndIf
If hr=00:hr$="00":EndIf
If state=0:state$="00":EndIf
If hr<10:hr$="0"+Str(hr):EndIf
If hr>9:hr$=Str(hr):EndIf
If state<10:state$="0"+Str(state):EndIf
If state>9:state$=Str(state):EndIf
StringGadget(5, 25, 29, 49, 23,"")
DisableGadget(5,1)
StringGadget(hours, 26, 30, 19, 20, hr$, #PB_String_Numeric | #PB_String_BorderLess)
SetGadgetFont(hours, FontID1)
SendMessage_(GadgetID(hours), #EM_LIMITTEXT, 2, 0)
StringGadget(sepa, 45, 30, 6, 20, ":", #PB_String_BorderLess)
SetGadgetFont(sepa, FontID1)
SendMessage_(GadgetID(sepa), #EM_LIMITTEXT, 1, 0)
SpinGadget(spin, 72, 30, 10, 20, -1, 60)
StringGadget(mins, 51, 30, 20, 20, state$, #PB_String_Numeric | #PB_String_BorderLess)
SetGadgetFont(mins, FontID1)
SendMessage_(GadgetID(mins), #EM_LIMITTEXT, 2, 0)
Repeat
state=Val(GetGadgetText(4)):SetGadgetState(spin,state)
string = EventGadget()
If string=3 : SetActiveGadget(4):EndIf
EventID.l = WaitWindowEvent()
If eventid = #PB_Event_Gadget
ElseIf eventid = 15 :EndIf
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case spin
hr=Val(GetGadgetText(2))
state=GetGadgetState(spin)
evtp=EventType()
If state>60:SetGadgetState(spin,59):hr=hr-1:EndIf
If state>59 And state <70 :hr=hr+1:SetGadgetState(spin,0):state=0:EndIf
If state<10:SetGadgetText(4,"0"+Str(GetGadgetState(spin))):EndIf
If state>9:SetGadgetText(4,Str(GetGadgetState(spin))):EndIf
If hr<0 :hr=23:EndIf
If hr>23:hr=0:EndIf
If hr<10:SetGadgetText(2,"0"+Str(hr)):EndIf
If hr>9:SetGadgetText(2,Str(hr)):EndIf
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
Nessie
