Step Incremental SpinGadget Example

Share your advanced PureBasic knowledge/code with the community.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Step Incremental SpinGadget Example

Post by Zebuddi123 »

Hi to all. Needed a variable step incremental spingadget, thought it maybe useful to others

Zebuddi. :)

Code: Select all

#spingad= 0
#increment_step =15 

Procedure Increment_SpinGadget_AdjustValue() ; set 
	Select Gadget
		Case #spingad
			Select EventType()
				Case 4 ; spingadget up
					spin_value = (Val(GetGadgetText(#spingad)) + #Increment_step)
				Case 5 ; spingadget down
					spin_value = (Val(GetGadgetText(#spingad)) - #Increment_step)
			EndSelect
			SetGadgetText(#spingad, Str(spin_value))
	EndSelect
EndProcedure

If OpenWindow(0,0,0,140,70,"SpinGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
	
	; Set number of incremental steps in SpinGadget()  min/max paramaters  
	; in this example  there are 3 steps. min/max ignored  0, 15, 30, 45  ie: quater hour interval steps
	SpinGadget(#spingad, 20, 20, 100, 25, 1, 4, #PB_Spin_ReadOnly)
	
	SetGadgetText(#spingad, Str(0))
	BindGadgetEvent(#spingad, @Increment_SpinGadget_AdjustValue())
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
	
EndIf
malleo, caput, bang. Ego, comprehendunt in tempore