Here's a short simplified example of a problem I'm having.
What I want to achieve is a trackbar and a spinner that are synchronised and that can also be manipulated via code.
In the following example If you move the trackbar the spinner updates and vice versa - you can click the Start button and the text will change to Stop - it works - but when you enable the updates to either the trackbar or the spinner via code the events generated by this prevent the button event or anything else from ever getting "heard".
If you use WB3D_FlushEvents() then you flush everything including the button event so that doesn't help.
Is what I am trying to do possible? If so how do I filter out the events generated by code rather than user manipulation ?
Any help on this would be greatly appreciated.
What I want to achieve is a trackbar and a spinner that are synchronised and that can also be manipulated via code.
In the following example If you move the trackbar the spinner updates and vice versa - you can click the Start button and the text will change to Stop - it works - but when you enable the updates to either the trackbar or the spinner via code the events generated by this prevent the button event or anything else from ever getting "heard".
If you use WB3D_FlushEvents() then you flush everything including the button event so that doesn't help.
Is what I am trying to do possible? If so how do I filter out the events generated by code rather than user manipulation ?
Any help on this would be greatly appreciated.
Include "../../../WB3DStyles.bb" ; setup gfx mode. Graphics3D 640,480,16,2 Global switch=0 Global updatespinner=0 Global updatetrackbar=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) checkspinner=WB3D_CreateCheckButton ("Update Spinner",10, 140, 160, 20,example_window,0) checktrackbar=WB3D_CreateCheckButton ("Update Trackbar",10, 160, 160, 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)) Case checkspinner updatespinner= Not updatespinner Case checktrackbar updatetrackbar= Not updatetrackbar 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 If updatetrackbar WB3D_SetTrackBarPos (trackbar,count) If updatespinner 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