Skip to content
Search

WxWidgets:FirstProgram

lastmod 2014-09-04created 2014-09-041 edits

A sample of a first wxWidget program is shown below.

#include <wx/wx.h>

class Simple: public wxFrame
{
public:
    Simple(const wxString& title) :
            wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
    {
        Centre();
    }
};

class MyApp: public wxApp
{
public:
    virtual bool OnInit()
    {
        Simple *simple = new Simple(wxT("Simple"));
        simple->Show(true);

        return true;
    }
};

IMPLEMENT_APP(MyApp)

Note that the main() function is already included inside the wxWidgets library.

Favorite site