WinBlitz3d Events Help

Blitz3D Forums/Blitz3D Programming/WinBlitz3d Events Help

Those checkboxes and variables are just to switch conditions so you could see the events working and then not - they are irrelevant to the issue.
Here's a more basic example - Once you hit Start the button no longer responds :
Include "../../../WB3DStyles.bb"

; setup gfx mode.
Graphics3D 640,480,16,2
Global switch=0

; install winblitz3d.
Global RuntimeWindow_hWnd = WB3D_InitializeGUI(SystemProperty("AppHwnd"),10,10,300,200)
WB3D_SetQuitMessage "WinBlitz3D 3D/GUI","Sure To Quit" 
;WB3D_HideGadget RuntimeWindow_hWnd

; create winapi window, setting its title, and position on screen. use default style creation.
example_window = WB3D_CreateWindow("WB3D_CreateWindow Example",200,100,450,275,0,0)
trackbar = WB3D_CreateTrackBar%(10, 24, 200, 30,example_window,0,TBS_AUTOTICKS Or TBS_TOP Or WS_CHILD)
WB3D_SetTrackBarRange (trackbar,0,100)
WB3D_SetTrackBarPos (trackbar,0)
button=WB3D_CreateButton%("Start",10, 60, 60, 20,example_window,0)

thislabel = WB3D_CreateEditField("",10,100,30,20,example_window,0,0)
spinner = WB3D_CreateSpinner(40, 100,50,20,example_window,0,0)
WB3D_SetSpinnerRange (spinner,0,100)
WB3D_SetSpinnerPos (spinner,0)
; cleanup any old creation events, its better to do this before we enter the main
; event loop, when some gadgets are created they generate events.
WB3D_FlushEvents 

; setup out quit flag, and loop until the flag is set.
QUIT = 0
While Not QUIT = 1
	
	; generate an internal blitz event
	Flip
	Cls
	Text 10,10,selected
	; get an event of the event queue.
	event = WB3D_WaitEvent()
	Select event
		
		
		Case WB3D_EVENT_GADGET
			selected = WB3D_EventSource()
			
			Select selected
				Case button
					switch=Not switch
					If switch 
						WB3D_SetGadgetText(button,"Stop")
					Else
						WB3D_SetGadgetText(button,"Start")
					End If

				Case trackbar
					 WB3D_SetSpinnerPos(spinner,WB3D_GetTrackBarPos(trackbar))
				Case spinner
					 WB3D_SetTrackBarPos(trackbar,WB3D_GetSpinnerPos(spinner))
				
				
				
			
			End Select


		Case WB3D_EVENT_KEYPRESS
		
			; wb_eventdata holds the key code that was pressed.
			keypressed = WB3D_EventData()
			Select keypressed
				
				Case WB3D_KEY_ESCAPE	
					
					; set the flag to leave the loop.
					QUIT = 1
					
			End Select
				
		Case WB3D_EVENT_WINDOW_CLOSE
		
			; wb3d_eventsource hold the handle to the window that close button was selected
			window = WB3D_EventSource()
			Select window
			
				Case example_window
					
					; set the flag to leave the loop.
					QUIT = 1
					
			End Select
	End Select

	If switch
		count=count+1
			If count>100 count=0
				WB3D_SetTrackBarPos (trackbar,count)
				WB3D_SetSpinnerPos (spinner,count)
				;WB3D_FlushEvents();This will delete all events nothing left to capture !!!
			End If	
Wend

; use notify using external winapi constants. 
WB3D_Notify "WB3D GUI Window Example","Bye, Thats It I Quit",MB_OK Or MB_ICONASTERISK
WB3D_EndGUI()
EndGraphics
End

Basically what I am trying to do is have a trackbar and a spinner synchronised - when manipulated by the user. I also want to be able to manipulate them via code in the main program loop so flushing events is not an option because this flushes everything.
In the example the trackbar and spinner are synched - if you move one the other updates. If you try and manipulate the gadgets via code ,however , the resulting flood of events prevents any other event from beiing dealt with.
If there is no way to manipulate the gadgets via code without generating a lot of events that cannot be filtered or flushed out then I will have to rethink.