closing 1 of 2 windows

BlitzMax Forums/BlitzMax Programming/closing 1 of 2 windows

gellyware(Posted 2006) [#1]
I know this has been posted before but I can't find it with the new search.

If I have two windows open, how do I get only one to close?

I've tried something like this:

While Not done
			PollEvent()
			
			Select EventID()
				Case EVENT_WINDOWCLOSE   
					If EventSource() = sWindow 
						done = True 
						FreeGadget(sWindow)
					EndIf 
endselect 

but both windows close when I click the X to close "swindow", even though one is named window and one is named swindow.


Dreamora(Posted 2006) [#2]
is window child of swindow? (instead both beeing child of null)


Grisu(Posted 2006) [#3]
Well, I made global var that tells me which window is currently open, so I know which window to close.


WendellM(Posted 2006) [#4]
Could perhaps be tweaked, but one idea is:

Strict

Local Window:TGadget = CreateWindow( "Window", 10,10, 400,200)
Local sWindow:TGadget = CreateWindow( "sWindow", 10,300, 400,200)

Repeat
	PollEvent
	If EventID() = EVENT_WINDOWCLOSE Then
		If EventSource() = Window Then
			FreeGadget Window
			Window = Null
		EndIf
		If EventSource() = sWindow Then
			FreeGadget sWindow
			sWindow = Null
		EndIf
		If (Window=Null) And (sWindow=Null) Then End
	EndIf
Forever



gellyware(Posted 2006) [#5]
I'm still having trouble managine two different window contents. Thanks for the code WendellM, only problem is nothing is going on with those windows.

I'm currently trying to manage the Sudoku Maya game in one window, and a 'sudoku print' app that is in a second window. (this appears when the user presses print). I can't seem to come to terms with a way to handle both within the same framework.

I've tried this, but it isn't working out too well:

If EventID() = EVENT_WINDOWACTIVATE
  globalWindow = EventSource()
End If

if globalWindow = window
   'do sudoku maya window code'
else if globalWindow = sWindow (the sudoku print window)
   'do print window code'
endif