Table of contents
How is the wxWidgets app instantiated?
#include <wx/wx.h>
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
wxIMPLEMENT_APP(MyApp); //calls MyApp declared above
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
}
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame("Hello World", wxDefaultPosition, wxDefaultSize);
frame->Show(true);
return true;
}
MyFrame::MyFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
: wxFrame(nullptr, wxID_ANY, title, pos, size)
{
}
Following is the callstack:
1 MyFrame::MyFrame main.cpp,
MyFrame::MyFrame
2 MyApp::OnInit main.cpp,
bool MyApp::OnInit()
3 wxAppConsoleBase::CallOnInit app.h,
virtual bool CallOnInit() {return OnInit();}
4 wxEntry init.cpp
5 wxEntry init.cpp
6 main main.cpp,
wxIMPLEMENT_APP(MyApp);