; English forum: http://purebasic.myforums.net/viewtopic.php?t=6885&highlight= ; Author: ricardo ; Date: 12. July 2003 ; In resume there are 2 important things: ; 1.- Check which window receives the #PB_EventCloseWindow by using the EventWindowID() ; that let you know which one was. ; 2.- The Gadgets of you additional windows must have different number ids from the ; ones of the main window, then it could be handled in the same event loop. Procedure AnotherWindow() If OpenWindow(1,100,150,250,200,#PB_Window_SystemMenu,"OtherWindow") CreateGadgetList(WindowID()) ButtonGadget(11,100,100,50,25,"Test") EndIf EndProcedure If OpenWindow(0,0,0,450,200,#PB_Window_SystemMenu,"Test") CreateGadgetList(WindowID()) ButtonGadget(1,150,100,150,25,"Open another window") Repeat EventID=WaitWindowEvent() Select EventID Case #PB_EventGadget Select EventGadgetID() Case 1 AnotherWindow() Case 11;The gadget from the other window must have DIFFERENT ids MessageRequester("click","Button from 2nd window",0) EndSelect Case #PB_EventCloseWindow If EventWindowID()= 1 ;Here you detect if the window to close is your additional window CloseWindow(1) UseWindow(0) Else Quit = 1 EndIf EndSelect Until Quit = 1 EndIf ; ExecutableFormat=Windows ; FirstLine=1 ; EnableXP ; EOF