collectordave wrote:
Logic to me dictates that i should not do anything I do not have to.
TI-994A wrote
Sound logic; try following it:
Ok. I will try to follow some logic.
This topic is "Multiple Window problem".
The first post demonstrates that problem.
Lots of forum members attempted to look at the problem sometimes a little illogically until
fred Wrote
You should always check for a valid PB event, and ignore all other as they are generated by the OS
and a little light started to shine. It became apparent that EventWindow() could return erronous results until a valid PB event had happened.
of course the forum carried on a little until said posted a solution which actually worked and demonstrated what fred had said.
Checking microsoft you find a little advice. Each window should have it's own event handling procedure and in multiple windows applications it is the responsibility of the applications main message loop to route events to the correct window. Which also makes sense logicaly as why attempt to process events from other windows in the main window event loop?
So useing logic it is best when programming windows to follow microsofts advice.
To do this the EventWindow() procedure needs to work reliably, which can only be guaranteed after a valid pb event.
TI-994A wrote
Assume you have a window with a button and a timer; how do you propose handling each of those events?
After this I posted a working example showing how to process the timer event and a button with the EventWindow() function working correctly.
the reply to this was
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Timer
If EventTimer() = 0
Value = (Value + 5) % 100
SetGadgetState(1, Value)
EndIf
Case #PB_Event_Gadget
If EventGadget() = 0
Debug "buttonpressed"
EndIf
EndSelect
Until appQuit
The code only needs to check for the occurrence of three events; all others are moot and require no scrutiny whatsoever.
Which appears to be a little illogical in this topic of multiple window problem especially after all the posts here have shown that there is an undocumented feature of EventWindow(). To achieve what you are saying there the programme posted simply processes only the events needed. The checkevent() procedure is not processing any events at all just checking that the event that occurred was a valid PB event.
Repeat
event = WaitWindowEvent()
If CheckEvent(event) = #True
If Event = #PB_Event_Timer And EventTimer() = 123
Value = (Value + 5) % 100
SetGadgetState(0, Value)
EndIf
Select EventGadget()
Case Button_0
Debug "buttonpressed"
EndSelect
EndIf
Until event = #PB_Event_CloseWindow
Just about the same except still showing the workaround of the undocumented feature of EventWindow() which keeps us on topic showing the resolution of the Multiple window problem.
Logic then leads me to ask why have you posted here again.
I can imagine a few scenarios.
1. You do not understand the problem.
2. You do not fully understand the processing of windows events
3. You have a problem with logical thinking so cannot accept EventWindow() has an undocumented feature.
4. You are deliberatly attempting to draw the forum users offtopic and attempting to prove what is stated here is incorrect.
I cannot believe the fourth scenario. So I do recommend Programming 101.If it is the third then I am afraid I cannot help.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.