I am trying to make an input box for my GUI app using wxTextCtrl.
I've made the box but when I'm trying to take the input text from it, it crashes and I can't figure out why.
Here is the code:
main.cpp:
int main(int argc, char** argv)
{
wxApp::SetInstance( new App() );
wxEntryStart(argc, argv);
wxTheApp->OnInit();
wxTheApp->OnRun();
wxTheApp->OnExit();
wxEntryCleanup();
return 0;
}
app.cpp:
bool App::OnInit()
{
wxString title = "Version: ";
title += APP_VERSION;
/* Create the frame for my app */
Frame *simple = new Frame(0, wxID_ANY, title, wxDefaultPosition, wxSize(287, 700)/*wxSize(287, 450)*/, (wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX)));
simple->Show(true);
return true;
}
frame.cpp:
Frame::Frame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
: wxFrame( parent, id, title, pos, size, style )
{
wxPanel *panel = new wxPanel(this, wxID_ANY);
input_text = new wxTextCtrl(this, wxID_ANY, "initial", wxPoint(10, 400), wxSize(250, 100));
wxString str = input_text->GetValue();
wxMessageBox(str);
}
It crashes in frame.cpp on the line: wxString str = input_text->GetValue();
I'm compiling on windows using wxWidgets-3.0.0 and Visual Studio 2012.
This may be something very simple but I just started working with wxWidgets and I don't have much experience with it.
Thanks.