offsides wrote:Documented or not, they worked and became part of the code base we learn PB from. Now, some work, some don't.
For some the advantage compared to the callback (apart less code) it's you can process both #PB_Events and #WM_* messages easily in the same loop.
Keep in mind that now, with the new PostEvent() command, you can use the "clean" callback method and still process the messages in the PB event loop, if you choose to do so.
At least that's my take, I haven't experimented with PostEvent() until now
Example:
Code: Select all
Enumeration
#My_Event_LeftClick_Down = #PB_Event_FirstCustomValue
#My_Event_RightClick_Down
EndEnumeration
Procedure wc (hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_LBUTTONDOWN
PostEvent(#My_Event_LeftClick_Down)
Case #WM_RBUTTONDOWN
PostEvent(#My_Event_RightClick_Down)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0,0,0,200,200,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowCallback(@wc())
Repeat
eventid = WaitWindowEvent()
Select eventid
Case #PB_Event_CloseWindow
quit=1
Case #My_Event_LeftClick_Down
Debug "Left button Down"
Case #PB_Event_LeftClick
Debug "Left button up"
Case #My_Event_RightClick_Down
Debug "Right button down"
Case #PB_Event_RightClick
Debug "Right button up"
EndSelect
Until quit
EndIf
Obviously in this case you get only the message/event type and not the associated lParam / wParam, but if needed they can always be squeezed in the Data param of PostEvent(). This is ok if you just want to use them in readonly mode. If you have to block the message or do other tricky things the right place it's still the callback.
So you have many choices:
use the undocumented #WM_ returned by (Wait)WindowEvent() and possibly the undocumented EventlParam() / EventWParam()
use the SetWindowCallback() and process only the #WM_ messages there (the #PB_Events still in the PB loop)
use the SetWindowCallback() and forward the #WM_ messages you want to process as PB events through PostEvent() (like in the above example) when it's easier / more comfortable to do so.
Hope this helps.