Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
class MainFrame: public wxFrame
{
public:
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
wxButton * button;
wxTextCtrl * text;
void OnChangeBgClicked(wxCommandEvent& event);
DECLARE_EVENT_TABLE();
};
enum
{
ID_CHANGE_BG_BUTTON = 1
};
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_BUTTON(ID_CHANGE_BG_BUTTON, MainFrame::OnChangeBgClicked)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
MainFrame *frame = new MainFrame(wxT("bgtest"), wxPoint(50, 50), wxSize(450, 340));
frame->Show(true);
return true;
}
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size)
{
this->button = new wxButton(this, ID_CHANGE_BG_BUTTON, wxT("change bg"));
this->text = new wxTextCtrl(this, wxID_ANY);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(this->button);
sizer->Add(this->text);
SetSizerAndFit(sizer);
}
void MainFrame::OnChangeBgClicked(wxCommandEvent& event)
{
this->text->SetBackgroundColour(wxT("pink"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.