Listing 1. Creating a wxApp Class

#include "wx/wx.h"
#include "mondrian.xpm"

// Define a new application class
class MyApp : public wxApp {
    public:
    // Initialize app
    virtual bool OnInit();
};

// Define a new frame type as the main frame
class MyFrame : public wxFrame {
    public:
    MyFrame(const wxString& title,
            const wxPoint& pos,
            const wxSize& size,
            long style = wxDEFAULT_FRAME_STYLE);

// event handlers (not virtual!)
    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);

    private:

    // declare event table
    DECLARE_EVENT_TABLE()
};

// Create a new application object
IMPLEMENT_APP(MyApp)

// 'Main App' equivalent
bool MyApp::OnInit()
{
    // create the main application window
    MyFrame *frame =
    new MyFrame(_T("Example"),
                wxPoint(50, 50), wxSize(450, 340));
    frame->Show(TRUE);
    return TRUE;
}