Closing a Frame

BlitzMax Forums/Brucey's Modules/Closing a Frame

Glenn Dodd(Posted 2008) [#1]
I want to close Frame2 when a button is clicked.
I thought frame2.show(False) would have been enough to bring Frame1 to the front again.
But i get an "Unhandled Exception: Attempt to access field or method of Null Object"

testFormOpening_Main.bmx


testFormOpening_GUI.bmx


Regards
glenn


Brucey(Posted 2008) [#2]
The variable/field frame2 in your Button2Clicked method is Null. You never set it to anything.


Glenn Dodd(Posted 2008) [#3]
true.
the question still remains though.
i want to unshow frame2 so frame1 reappears, or destroy frame2 if necessary, like clicking on the x in the top right hand corner.

I know this should be incredibly simple but ... i don't appear to be doing "simple" today.


Brucey(Posted 2008) [#4]
I trust that your frames are just basic examples, as they are otherwise practically identical?

Anyhoo, how about :
	Method Button2Clicked(event:wxCommandEvent)
		Close()
	End Method


What were you intending your frame2 field in MyFrame2 to represent? itself, or a third frame?


Glenn Dodd(Posted 2008) [#5]
i put the frame2 field in because it complained on the frame2.show(false) line without it.
amazingly the close() command on its own never even occurred to me.
i was trying to reference it back to itself in my previous attempts.

Many thanks