Code: Select all
EVT_COMMAND_RANGE ( 10001 , 10020, wxEVT_COMMAND_BUTTON_CLICKED , MainFrame::OnClick )
wxPanel* MainFrame::BuildEventPanel()
{
wxPanel *panel = new wxPanel ( this , wxID_ANY );
wxBoxSizer *buttonSizer1 = new wxBoxSizer ( wxHORIZONTAL );
wxButton *bn1 = new wxButton ( panel , 10001 , wxT("Button1") );
wxButton *bn2 = new wxButton ( panel , 10002 , wxT("Button2") );
wxButton *bn3 = new wxButton ( panel , 10003 , wxT("Button3") );
wxButton *bn4 = new wxButton ( panel , 10004 , wxT("Button4") );
wxButton *bn5 = new wxButton ( panel , 10005 , wxT("Button5") );
buttonSizer1->Add ( bn1 , 0 , wxALL , 5 );
buttonSizer1->Add ( bn2 , 0 , wxALL , 5 );
buttonSizer1->Add ( bn3 , 0 , wxALL , 5 );
buttonSizer1->Add ( bn4 , 0 , wxALL , 5 );
buttonSizer1->Add ( bn5 , 0 , wxALL , 5 );
wxBoxSizer *buttonSizer2 = new wxBoxSizer ( wxHORIZONTAL );
wxButton *bn6 = new wxButton ( panel , 10006 , wxT("Button6") );
wxButton *bn7 = new wxButton ( panel , 10007 , wxT("Button7") );
wxButton *bn8 = new wxButton ( panel , 10008 , wxT("Button8") );
wxButton *bn9 = new wxButton ( panel , 10009 , wxT("Button9") );
wxButton *bn10 = new wxButton ( panel , 10010 , wxT("Button10") );
buttonSizer2->Add ( bn6 , 0 , wxALL , 5 );
buttonSizer2->Add ( bn7 , 0 , wxALL , 5 );
buttonSizer2->Add ( bn8 , 0 , wxALL , 5 );
buttonSizer2->Add ( bn9 , 0 , wxALL , 5 );
buttonSizer2->Add ( bn10 , 0 , wxALL , 5 );
wxBoxSizer *buttonSizer = new wxBoxSizer ( wxVERTICAL );
buttonSizer->Add ( buttonSizer1 , 0 , wxALL , 10 );
buttonSizer->Add ( buttonSizer2 , 0 , wxALL , 10 );
panel->SetAutoLayout(true);
panel->SetSizer(buttonSizer);
buttonSizer->Fit(panel);
buttonSizer->SetSizeHints(panel);
return panel;
}
void MainFrame::OnClick(wxCommandEvent& event )
{
wxMessageBox ( wxString::Format( wxT("Button(%d) clicked") , event.GetId()));
event.Skip();
}
void MainFrame::OnPlayMacro(wxCommandEvent& WXUNUSED(event))
{
wxCommandEvent event;
event.SetId(10012);
event.SetEventObject( this );
GetEventHandler()->ProcessEvent( event );
}
I am trying to execute OnPlayMacro function inorder to execute the OnClick() event programatically. Of course I have hard coded the button id, but it can be any be any valid button id with in the definied range.
When I execute the OnPlayMacro() this is not processing the event. Any help on how to fix this issue will be greatly appreciated.
Thanks.
VSP.