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
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
' ' Example application stub generated by wxCodeGen v1.06 : 05 Aug 2008 15:09:10 ' SuperStrict Framework wx.wxApp Import "testFormOpening_GUI.bmx" New MyApp.run() Type MyApp Extends wxApp Field frame:MyFrame1 Method OnInit:Int() ?macos ' make the default Mac font for controls not so big wxSystemOptions.SetOption(wxWINDOW_DEFAULT_VARIANT, wxWINDOW_VARIANT_SMALL) ? ' create the frame Local frame:MyFrame1 = MyFrame1(New MyFrame1.Create(, , "Frame 1")) ' frames are created hidden. You need to manually show it. frame.show() ' make sure it is brought to the front SetTopWindow(frame) Return True End Method End Type Type MyFrame1 Extends MyFrame1Base Field frame2:MyFrame2 Method OnInit() Super.OnInit() End Method Method ButtonClicked(event:wxCommandEvent) ' Make the second Frame appear when this button is clicked Local frame2:MyFrame2 = MyFrame2(New MyFrame2.Create(,, "Frame 2")) frame2.show(True) End Method End Type Type MyFrame2 Extends MyFrame2Base Field frame2:MyFrame2 Method OnInit() Super.OnInit() End Method Method Button2Clicked(event:wxCommandEvent) ' --------------------------------------------------------------------- ' How do i make the second Frame disappear when this button is clicked? ' --------------------------------------------------------------------- frame2.show(False) End Method End Type
testFormOpening_GUI.bmx
' ' BlitzMax code generated with wxCodeGen v1.06 : 05 Aug 2008 15:09:10 ' ' ' PLEASE DO "NOT" EDIT THIS FILE! ' SuperStrict Import wx.wxButton Import wx.wxFrame Import wx.wxPanel Import wx.wxWindow Type MyFrame1Base Extends wxFrame Field m_panel1:wxPanel Field m_button1:wxButton Method Create:MyFrame1Base(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "", x:Int = -1, y:Int = -1, w:Int = 500, h:Int = 300, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL) Return MyFrame1Base(Super.Create(parent, id, title, x, y, w, h, style)) End Method Method OnInit() Local bSizer1:wxBoxSizer bSizer1 = New wxBoxSizer.Create(wxVERTICAL) m_panel1 = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL) bSizer1.Add(m_panel1, 1, wxEXPAND | wxALL, 5) m_button1 = New wxButton.Create(Self, wxID_ANY, "MyButton") bSizer1.Add(m_button1, 0, wxALL, 5) SetSizer(bSizer1) Layout() m_button1.ConnectAny(wxEVT_COMMAND_BUTTON_CLICKED, _ButtonClicked, Null, Self) End Method Function _ButtonClicked(event:wxEvent) MyFrame1Base(event.sink).ButtonClicked(wxCommandEvent(event)) End Function Method ButtonClicked(event:wxCommandEvent) DebugLog "Please override MyFrame1.ButtonClicked()" event.Skip() End Method End Type Type MyFrame2Base Extends wxFrame Field m_panel2:wxPanel Field m_button2:wxButton Method Create:MyFrame2Base(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "", x:Int = -1, y:Int = -1, w:Int = 500, h:Int = 300, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL) Return MyFrame2Base(Super.Create(parent, id, title, x, y, w, h, style)) End Method Method OnInit() Local bSizer2:wxBoxSizer bSizer2 = New wxBoxSizer.Create(wxVERTICAL) m_panel2 = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL) bSizer2.Add(m_panel2, 1, wxEXPAND | wxALL, 5) m_button2 = New wxButton.Create(Self, wxID_ANY, "MyButton2") bSizer2.Add(m_button2, 0, wxALL, 5) SetSizer(bSizer2) Layout() m_button2.ConnectAny(wxEVT_COMMAND_BUTTON_CLICKED, _Button2Clicked, Null, Self) End Method Function _Button2Clicked(event:wxEvent) MyFrame2Base(event.sink).Button2Clicked(wxCommandEvent(event)) End Function Method Button2Clicked(event:wxCommandEvent) DebugLog "Please override MyFrame2.Button2Clicked()" event.Skip() End Method End Type
Regards
glenn