Closing child windows without shutting down the entire application?
Posted: Sun Dec 15, 2024 1:56 am
Hi,
I have an app using BindEvent to handle all its events, and it also has multiple child windows that pop out next to the main window. When I close a child window I should be returned to the main window, the app shouldn't exit. Here's a tiny example:
Originally, I had it be Until WaitWindowEvent(1) = #PB_Event_CloseWindow, but that didn't work because it came from any window. I also tried adding a check for And EventWindow() = #Window_Main, but that was unsuccessful, same as the approach shown above, the entire app shuts down upon me closing the child window. Providing a parent ID didn't seem to fix this either.
What am I missing?
Thanks!
I have an app using BindEvent to handle all its events, and it also has multiple child windows that pop out next to the main window. When I close a child window I should be returned to the main window, the app shouldn't exit. Here's a tiny example:
Code: Select all
EnableExplicit
Enumeration Windows
#Window_Main
#Window_Popup
EndEnumeration
Enumeration Gadgets
#Gadget_PopupButton
#Gadget_CloseButton
EndEnumeration
Procedure PopupWindowEvents()
Select EventGadget()
Case #Gadget_CloseButton
CloseWindow(#Window_Popup)
EndSelect
EndProcedure
Procedure CreatePopupWindow()
OpenWindow(#Window_Popup, #PB_Ignore, #PB_Ignore, 600, 400, "Subwindow")
ButtonGadget(#Gadget_CloseButton, 10, 10, 50, 50, "Close")
BindEvent(#PB_Event_Gadget, @PopupWindowEvents())
SetActiveGadget(#Gadget_CloseButton)
EndProcedure
Procedure MainWindowEvents()
Select EventGadget()
Case #Gadget_PopupButton
CreatePopupWindow()
EndSelect
EndProcedure
Procedure MainWindowCloseHandler()
End
EndProcedure
OpenWindow(#Window_Main, #PB_Ignore, #PB_Ignore, 600, 400, "Test")
ButtonGadget(#Gadget_PopupButton, 10, 10, 50, 50, "Show popup")
BindEvent(#PB_Event_Gadget, @MainWindowEvents())
BindEvent(#PB_Event_CloseWindow, @MainWindowCloseHandler())
SetActiveGadget(#Gadget_PopupButton)
Repeat
Define Event = WaitWindowEvent(1)
ForEver
What am I missing?
Thanks!