Additional parameter for WindowEvent and WaitWindowEvent
Additional parameter for WindowEvent and WaitWindowEvent
Like in NetworkServerEvent() you should be able to add the Window as parameter.
Then you can handle different windows in different event loops.
This makes sense if you need a hidden window as callback receiver (like for playing MIDI in windows)
Then you can handle this without disturbing the rest.
Then you can handle different windows in different event loops.
This makes sense if you need a hidden window as callback receiver (like for playing MIDI in windows)
Then you can handle this without disturbing the rest.
Re: Additional parameter for WindowEvent and WaitWindowEvent
+1
Also useful if like on my case you have a window inside a dll (not a good practice, I know, but works nice on Windows)
Also useful if like on my case you have a window inside a dll (not a good practice, I know, but works nice on Windows)

Re: Additional parameter for WindowEvent and WaitWindowEvent
After a WindowEvent() or WaitWindowEvent() function, use this function to determine on which window the event has occurred.
Thus, one can separate the further event processing.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Additional parameter for WindowEvent and WaitWindowEvent
+1. This would be super useful.
Re: Additional parameter for WindowEvent and WaitWindowEvent
This will simply insert the following construction into your code
Code: Select all
Bool(WaitWindowEvent() And EventWindow() = #Wim1)
Re: Additional parameter for WindowEvent and WaitWindowEvent
...Okay?AZJIO wrote: Mon Jun 09, 2025 1:43 pm This will simply insert the following construction into your codeCode: Select all
Bool(WaitWindowEvent() And EventWindow() = #Wim1)
What is your point exactly?
Being able to use a bool expression to do the same thing does not mean the feature shouldn't be asked for/implemented...

Re: Additional parameter for WindowEvent and WaitWindowEvent
That does not work. You get the event already by calling WaitWindowEvent().AZJIO wrote: Mon Jun 09, 2025 1:43 pm This will simply insert the following construction into your codeCode: Select all
Bool(WaitWindowEvent() And EventWindow() = #Wim1)
So if it does not fit EventWindow(), you lost this event.
Re: Additional parameter for WindowEvent and WaitWindowEvent
And BindEvent() is also not possible.
It does not work for #MM_MCINOTIFY for example.
So I can not open a hidden window and proccess the MIDI CallBack in the background.
It does not work for #MM_MCINOTIFY for example.
So I can not open a hidden window and proccess the MIDI CallBack in the background.
Re: Additional parameter for WindowEvent and WaitWindowEvent
Code: Select all
Procedure WaitWindowEvent2(wnd_id)
Protected Result
If EventWindow() = wnd_id
Result = WaitWindowEvent()
EndIf
ProcedureReturn Result
EndProcedure
Event = WaitWindowEvent2(#Wim1)
Re: Additional parameter for WindowEvent and WaitWindowEvent
You can call EventWindow first when WindowEvent or WaitWinowEvent returns.AZJIO wrote: Tue Jun 10, 2025 4:12 amCode: Select all
Procedure WaitWindowEvent2(wnd_id) Protected Result If EventWindow() = wnd_id Result = WaitWindowEvent() EndIf ProcedureReturn Result EndProcedure Event = WaitWindowEvent2(#Wim1)
So you loose one event if it is not for your specified window.
Re: Additional parameter for WindowEvent and WaitWindowEvent
If you call WindowEvent() and WaitWinowEvent(), which both capture the event, you can skip it. But EventWindow() does not capture the event, but gets the window in which the event occurred. The help for EventWindow() says that the function should be called after capturing events.infratec wrote: Tue Jun 10, 2025 6:49 am You can call EventWindow first when WindowEvent or WaitWinowEvent returns.
Code: Select all
Procedure WaitWindowEvent2(wnd_id)
Protected Result
Result = WaitWindowEvent()
If EventWindow() <> wnd_id
Result = 0
EndIf
ProcedureReturn Result
EndProcedure
Event = WaitWindowEvent2(#Wim1)
Re: Additional parameter for WindowEvent and WaitWindowEvent
I think infratec is correct, the WaitWindowEvent() in your example consume an event so if it's not from the correct window, the event is lost, not repeated on the other event loop.
Re: Additional parameter for WindowEvent and WaitWindowEvent
There should only ever be one call to (Wait)WindowEvent().
In this loop, you can split the events depending on the window to be processed further
The window number is also entered for each valid event.
In this loop, you can split the events depending on the window to be processed further
The window number is also entered for each valid event.
Code: Select all
;-TOP
#ProgramTitle = "Main Window"
#Version = "v1.01.1"
Enumeration Windows
#Main
#Diaglog1
#HideWindow
EndEnumeration
Enumeration Menus
#MainMenu
EndEnumeration
Enumeration MenuItems
#MainMenuExitApplication
EndEnumeration
Enumeration Gadgets
EndEnumeration
Enumeration Status
#MainStatusBar
EndEnumeration
Global ExitApplication
; ----
Procedure DoEventsMain(Event)
Select Event
Case #PB_Event_CloseWindow
ExitApplication = #True
Case #PB_Event_Menu
Select EventMenu()
Case #MainMenuExitApplication
ExitApplication = #True
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
EndProcedure
Procedure DoEventsDialog1(Event)
Select Event
Case #PB_Event_CloseWindow
; TODO
CloseWindow(#Diaglog1)
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
EndProcedure
Procedure DoEventsHideWindow(Event)
Select Event
Case #PB_Event_CloseWindow
; TODO
CloseWindow(#HideWindow)
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_Timer
Select EventTimer()
Case 1
Debug "Timer"
EndSelect
EndSelect
EndProcedure
; ----
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
; Resize gadgets
EndProcedure
; ----
Procedure OpenHideWindow()
If OpenWindow(#HideWindow, 0, 0, 0, 0, "EventTimer", #PB_Window_Invisible, WindowID(#Main))
AddWindowTimer(#HideWindow, 1, 1000)
EndIf
EndProcedure
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
; Menu
CreateMenu(#MainMenu, WindowID(#Main))
MenuTitle("File")
MenuItem(#MainMenuExitApplication, "E&xit")
; For Mac
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
If Not IsMenu(#MainMenu)
CreateMenu(#MainMenu, WindowID(#Main))
EndIf
MenuItem(#PB_Menu_About, "")
MenuItem(#PB_Menu_Preferences, "")
CompilerEndIf
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
StatusBarText(#MainStatusBar, 0, " " + #Version)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
; Bind events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
OpenHideWindow()
; Main loop
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case #Main
DoEventsMain(Event)
Case #Diaglog1
DoEventsDialog1(Event)
Case #HideWindow
DoEventsHideWindow(Event)
EndSelect
Until ExitApplication
EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Additional parameter for WindowEvent and WaitWindowEvent
I don't think it will be possible to do that, as there is a single queue for event, so if you want to filter for a specific window, all other events needs to be stored somewhere and it will create issues for sure with callbacks. @mk-soft just shown the right way to do it.