+
+ wxPanel * const panel = new wxPanel(this);
+ wxSizer * const mainSizer = new wxBoxSizer(wxVERTICAL);
+ wxSizer * const sizer = new wxBoxSizer(wxHORIZONTAL);
+ const wxSizerFlags centreY(wxSizerFlags().Centre().Border());
+ sizer->Add(new wxStaticText(panel, wxID_ANY,
+ "This button will only work if its handler is dynamically connected"),
+ centreY);
+ m_btnDynamic = new wxButton(panel, Event_Dynamic, "&Dynamic button");
+ sizer->Add(m_btnDynamic, centreY);
+
+ mainSizer->Add(sizer, 1, wxEXPAND);
+ mainSizer->Add(new wxStaticLine(panel), 0, wxEXPAND);
+ mainSizer->Add(new wxStaticLine(panel), 0, wxEXPAND);
+
+ m_testBtn = new MyEvtTestButton(panel, "Test Event Handlers Execution Order");
+
+ // After being created, an instance of MyEvtTestButton already has its own
+ // event handlers (see class definition);
+
+ // Add a dynamic handler for this button event in the parent frame
+ Connect(m_testBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
+ wxCommandEventHandler(MyFrame::OnClickDynamicHandlerFrame));
+
+ // Bind a method of this frame (notice "this" argument!) to the button
+ // itself
+ m_testBtn->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
+ wxCommandEventHandler(MyFrame::OnClickDynamicHandlerButton),
+ NULL,
+ this);
+
+ mainSizer->Add(m_testBtn);
+ panel->SetSizer(mainSizer);