[MaxGUI] multiple windows...

BlitzMax Forums/BlitzMax Beginners Area/[MaxGUI] multiple windows...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have a new problem :)
I have a main window and a secondary window. If I close the secondary window the program intercept the event 'Close window' and stop the program.
How can I know WHO is the Source of the close event? I tried with EventSource() that should return the source object but I have an error...or probably I miss something!
Please clarify me!
Thanks
Global win_main:tgadget
Global win_opt:tgadget

win_main=CreateWindow("Main Window",50,50,200,200)
win_opt=CreateWindow("Option",100,100,100,100)

While WaitEvent()
	evID=EventID()
	evsource=EventSource()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			evSource=EventSource()'???? <---tgadget(EventSource())?
			evID=EventID()
			
			If evSource=win_opt And win_opt<>0 FreeGadget win_opt
			If evSource=win_main
				If win_opt<>Null FreeGadget win_opt
				FreeGadget win_main
				End
			End If
	EndSelect
Wend