[MaxGUI] multiple windows...

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

degac(Posted 2005) [#1]
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



Perturbatio(Posted 2005) [#2]
Is this what you mean?
Global Window1:TGadget = CreateWindow("Window 1", 100,100,400,400)
	Global Button1:TGadget = CreateButton("Show", 10,10,100,25, Window1)
Global Window2:TGadget = CreateWindow("Window 2", 550, 100, 400,400)



While Not quit
	WaitEvent()
	
	Select EventID()
		Case EVENT_WINDOWCLOSE
			Select EventSource()
				Case Window1
					quit = True
				Case Window2
					HideGadget(Window2)
			End Select
		Case EVENT_GADGETACTION
			Select EventSource()
				Case Button1
					ShowGadget(Window2)
			End Select
	End Select
	
Wend

End



degac(Posted 2005) [#3]
Ok works fine, thank you very much!
At last I found were I was wrong..
evSource:Object=EventSource()
If evSource=window2 And window2<>Null FreeGadget window2

I missed to declare evSource as Object...many thanks!!!