Good morning,
I wrote :
Case #PB_Event_CloseWindow
IfIsWindow(0)
CloseWindow(0)
ElseIf IsWindow(1)
CloseWindow(1)
EndIf
And it doesn't work.
I would like that by clicking the X of window 0, window 0 is closed
And by clicking on the X of window 1, window 1 is closed but not window 0
CloseWindow()
Re: CloseWindow()
You don't do it right
You must use: EventWindow() to know wich window produce the event.
IsWindow is only to know if a window is a window really
You must use: EventWindow() to know wich window produce the event.
IsWindow is only to know if a window is a window really
Re: CloseWindow()
Hello Caronte3D,
thank you, it works great
thank you, it works great
Re: CloseWindow()
Maybe
...but now you don't have an option to stop the program.
Code: Select all
;Create Windows
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
CloseWindow(EventWindow())
EndSelect
ForEver
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: CloseWindow()
Thank you jacdelad
Re: CloseWindow()
Code: Select all
If OpenWindow(0, 0, 0, 220, 100, "Ex1", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget (1, 10, 60, 200, 30, "Close all")
OpenWindow(1, 100, 0, 220, 100, "Ex2", #PB_Window_SystemMenu )
OpenWindow(2, 200, 200, 220, 100, "Ex3", #PB_Window_SystemMenu )
Repeat
Event = WaitWindowEvent()
Win = EventWindow()
Select Event
Case #PB_Event_CloseWindow
Select win
Case 0
quit=1
Case 1,2
CloseWindow(Win)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 1
CloseWindow(0)
End
EndSelect
EndSelect
Until quit=1
EndIf
Re: CloseWindow()
Hello Mesa,
Thank you for this very clear example.
Thank you for this very clear example.
Re: CloseWindow()
I use a different selection nesting so that each window's events are enumerated in its own section of code.
Code: Select all
Enumeration
#Win0
#Win1
#Win2
EndEnumeration
#btn = 0
If OpenWindow(#Win0, 0, 0, 220, 100, "Ex1", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#btn, 10, 60, 200, 30, "Close all")
OpenWindow(#Win1, 100, 0, 220, 100, "Ex2", #PB_Window_SystemMenu )
OpenWindow(#Win2, 200, 200, 220, 100, "Ex3", #PB_Window_SystemMenu )
Repeat
WWE = WaitWindowEvent()
EvWin = EventWindow()
Select EvWin
Case #Win0
Select WWE
Case #PB_Event_Gadget
Select EventGadget()
Case #btn
; CloseWindow(#Win0)
End
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
Case #Win1
Select WWE
Case #PB_Event_CloseWindow
CloseWindow(#Win1)
EndSelect
Case #Win2
Select WWE
Case #PB_Event_CloseWindow
CloseWindow(#Win2)
EndSelect
EndSelect
ForEver
EndIf
Re: CloseWindow()
Thank You AZJIO