Page 1 of 1

Newbie question on closing a window

Posted: Wed Nov 27, 2013 11:10 pm
by TheMexican
First of all, I would like to say hello to all of you Purebasic users. I am new to Purebasic (Used to program in PHP and Python).
I have the following code:

Code: Select all

OpenWindow(0,0,0,200,200,"Window 1",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

OpenWindow(1,0,0,100,100,"Window 2",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

SetActiveWindow(0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
When I click and close a window, it closes both windows. How can I control closing a window without closing them all? I though the #PB_Event_CloseWindow should get caught by the active window?

Thanks

Using Purebasic 5.21 LTS

Re: Newbie question on closing a window

Posted: Wed Nov 27, 2013 11:37 pm
by IdeasVacuum

Code: Select all

Define iExit.i = False
Define iEvent.i

OpenWindow(0,0,0,200,200,"Window 1",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindow(1,0,0,100,100,"Window 2",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

Repeat
                  iEvent = WaitWindowEvent()
           Select iEvent

                   Case #PB_Event_CloseWindow

                        Select EventWindow()

                                    Case 0: CloseWindow(0) : iExit = #True
                                    Case 1: CloseWindow(1)
                        EndSelect
           EndSelect

Until iExit = #True
Welcome to PB and the Forum. You will like it here 8)

Re: Newbie question on closing a window

Posted: Thu Nov 28, 2013 3:49 am
by TheMexican
Thank you. Somehow I missed that CloseWindow() in the reference manual :oops:

Re: Newbie question on closing a window

Posted: Thu Nov 28, 2013 10:25 am
by infratec
No,

you missed

Code: Select all

EventWindow()
:mrgreen: :mrgreen: :mrgreen: