EventWindow() Undocumented feature
-
- Addict
- Posts: 1310
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
EventWindow() Undocumented feature
The EventWindow() function returns erronous results until after a valid PB event has occurred. The WindowEvent() and WaitWindowEvent() return all events whether valid PB events or not.
Can the documentation be amended to show this. A simple amedment such as:-
Description
After a WindowEvent() or WaitWindowEvent() function returns a valid PB event, use this function to determine on which window the event has occurred.
Can the documentation be amended to show this. A simple amedment such as:-
Description
After a WindowEvent() or WaitWindowEvent() function returns a valid PB event, use this function to determine on which window the event has occurred.
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.
Re: EventWindow() Undocumented feature
The manual has clearly indicated that the function is to be used only following an event.PureBasic Manual - EventWindow()
Description
After a WindowEvent() or WaitWindowEvent() function, use this function to determine on which window the event has occurred.
Return value
The window number on which the event has occurred.
No ambiguity; no bug.

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: EventWindow() Undocumented feature
collectordave wrote:
Thus a PureBasic program should act only on Official PB events in order to work properly.The WindowEvent() and WaitWindowEvent() return all events whether valid PB events or not.
Think Unicode!
Re: EventWindow() Undocumented feature
The possible 'correct' events are listed. In addition to these are custom events posted with PostEvent().PB Manual/WindowEvent() wrote:To get the window number in which the event occurred, use the EventWindow() function.
Possible Events are :
#PB_Event_Menu : a menu has been selected
#PB_Event_Gadget : a gadget has been pushed
#PB_Event_SysTray : an icon in the systray zone was clicked
#PB_Event_Timer : a timer has reached its timeout
#PB_Event_CloseWindow : the window close gadget has been pushed
#PB_Event_Repaint : the window content has been destroyed and must be repainted (useful for 2D graphics operations)
#PB_Event_SizeWindow : the window has been resized
#PB_Event_MoveWindow : the window has been moved
#PB_Event_MinimizeWindow : the window has been minimized
#PB_Event_MaximizeWindow : the window has been maximized
#PB_Event_RestoreWindow : the window has been restored to normal size (either from a minimum or maximum size)
#PB_Event_ActivateWindow : the window has been activated (got the focus)
#PB_Event_DeactivateWindow: the window has been deactivated (lost the focus)
#PB_Event_WindowDrop : a Drag & Drop operation was finished on a window
#PB_Event_GadgetDrop : a Drag & Drop operation was finished on a gadget
#PB_Event_RightClick : a right mouse button click has occurred on the window. This can be useful to display a popup menu
#PB_Event_LeftClick : a left mouse button click has occurred on the window
#PB_Event_LeftDoubleClick : a left mouse button double-click has occurred on the window
Notwistanding the fact that the manual already lists these things I am in favor of a more explicit statement such as the one that you suggested. You are not the first person to become confused by the 'natural order' to be followed in using theinformation functions for events.
-
- Addict
- Posts: 1310
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: EventWindow() Undocumented feature
The manual clearly states that, agreed. However at no point does it state that the value returned by the function is only valid after an official PB event.TI-994A wrote
The manual has clearly indicated that the function is to be used only following an event.
Just being a newbie to this I thought the reason your program acted only on Official PB events was to preserve the cross platform compatibility of the code, one of the real strengths of PB. The question then comes down to which events are Official PB events. The waitwindowevent() etc makes no distinction.ElementE wrote
Thus a PureBasic program should act only on Official PB events in order to work properly.
Thanks for the list Demivec. I have noticed that I am not the first to become confused with this. Those few extra words would make it quite clear so when posting for help on a problem, as I did, could then be answered quite simply by saying you are reacting to non Official PB events and not following the manual. Just giving me a DOH! moment and saving hours of fruitless work.
Can I assume that PostEvent() is something a more experienced programmer would use? Just asking as I have started converting a program from VB to PB which uses over forty windows/forms and would really enjoy not getting bitten again.
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.
Re: EventWindow() Undocumented feature
Yes, it is in the 'more advanced' category, but still simpler than pointerscollectordave wrote:Can I assume that PostEvent() is something a more experienced programmer would use? Just asking as I have started converting a program from VB to PB which uses over forty windows/forms and would really enjoy not getting bitten again.

It is used to send custom events to the PB message loop (or 'BindEvent' procedures). A possible use is as a communication method between threads to allow progressbars to update and such. It is strictly for communicating a custom event and is not acted on in any way by the OS. Check out its entry in the user manual for some sample code to illustrate its uses. Chances are you won't need it, but you never know.
Re: EventWindow() Undocumented feature
It's PureBasic, so logically, it only handles its prescribed events.collectordave wrote:The manual clearly states that, agreed. However at no point does it state that the value returned by the function is only valid after an official PB event.TI-994A wrote:The manual has clearly indicated that the function is to be used only following an event.
Once you stray off the reservation, into the lowlands of OS events, all bets are off, and it's no longer PureBasic's responsibility. Nevertheless, the ability to do so is yet another one of PureBasic's strengths.
The first rule of programming; GIGO.collectordave wrote:The question then comes down to which events are Official PB events. The waitwindowevent() etc makes no distinction.
Even professional programming languages like C/C++ don't make such distinctions. If you require such hand-holding, you'd be better off with a more managed language; like VB, perhaps.
It's very clear by now, that you don't read the manual or the posted answers to your questions.collectordave wrote:...could then be answered quite simply by saying you are reacting to non Official PB events and not following the manual ... saving hours of fruitless work.
Stick to the prescribed sequence, as indicated in the manual, and you won't go wrong.
You will, if you continue to use the big numbers that you love so much as object identifiers.collectordave wrote:...converting a program from VB to PB which uses over forty windows/forms and would really enjoy not getting bitten again.

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- Addict
- Posts: 1310
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: EventWindow() Undocumented feature
TI-994A wrote the abovecollectordave wrote
The EventWindow() function returns erronous results until after a valid PB event has occurred. The WindowEvent() and WaitWindowEvent() return all events whether valid PB events or not.
Can the documentation be amended to show this. A simple amedment such as:-
Description
After a WindowEvent() or WaitWindowEvent() function returns a valid PB event, use this function to determine on which window the event has occurred.
Sorry but I do not see the relevance of your post to this topic or the opening statements
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.
Re: EventWindow() Undocumented feature
I'm sure you don't; you never do.collectordave wrote:Sorry but I do not see the relevance of your post to this topic or the opening statements

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: EventWindow() Undocumented feature
Hello cd. From what I understand, he is saying that when the manual says "event" it is talking about PB events. Why should it be talking about events that PB does not support? You said that it should mention "official PB event" which is not necessary.collectordave wrote:TI-994A wrote the above
Sorry but I do not see the relevance of your post to this topic or the opening statements
"GIGO" means garbage in garbage out. You said that WaitWindowEvent makes no distinction but it is the coders responsibility to make sure that only the right data is processed. GIGO!
Finally about no one telling you about official PB events - he did -> http://www.purebasic.fr/english/viewtop ... 29#p474929
@TI-994A: Hope I got it right. What "big numbers" are you talking about?
Re: EventWindow() Undocumented feature
@fromVB: I'll sneak in and respond before TI-994A gets a chance. He means that in examples that collectordave has posted that collectordave uses high gadget or window numbers such as 1000 or 1001 when his example only has 2 of the item in question. collectordave doesn't realize that PB is reserving space for the 1000 (0 through 999) items that come before those numbers also.fromVB wrote:@TI-994A: Hope I got it right. What "big numbers" are you talking about?
I also think it's an important item but just don't think it needed to be emphasized at this point in collectordave's learning or in simple example code. It is hard to know how to do everything right the first time. It's OK to learn it in smaller steps.

Re: EventWindow() Undocumented feature
Thanks, fromVB and Demivec. Let's hope it gets through.
CodeInBasic Forum - Enumerations


Beautifully said! Although it has been said before; in some detail:Demivec wrote:I'll sneak in and respond before TI-994A gets a chance. He means that in examples that collectordave has posted that collectordave uses high gadget or window numbers such as 1000 or 1001 when his example only has 2 of the item in question. collectordave doesn't realize that PB is reserving space for the 1000 (0 through 999) items that come before those numbers also.
CodeInBasic Forum - Enumerations
With him, I wouldn't chalk it up to novice; it's more like willful indolence.Demivec wrote:I also think it's an important item but just don't think it needed to be emphasized at this point in collectordave's learning or in simple example code. It is hard to know how to do everything right the first time. It's OK to learn it in smaller steps.

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
