+#ifdef wxHAS_EVENT_BIND
+
+void MyFrame::OnBind(wxCommandEvent& event)
+{
+ if ( event.IsChecked() )
+ {
+ // as we bind directly to the button, there is no need to use an id
+ // here: the button will only ever get its own events
+ m_btnDynamic->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MyFrame::OnDynamic,
+ this);
+
+ // but we do need the id for the menu command as the frame gets all of
+ // them
+ Bind(wxEVT_COMMAND_MENU_SELECTED, &MyFrame::OnDynamic, this,
+ Event_Dynamic);
+ }
+ else // disconnect
+ {
+ m_btnDynamic->Unbind(wxEVT_COMMAND_BUTTON_CLICKED,
+ &MyFrame::OnDynamic, this);
+ Unbind(wxEVT_COMMAND_MENU_SELECTED, &MyFrame::OnDynamic, this,
+ Event_Dynamic);
+ }
+
+ UpdateDynamicStatus(event.IsChecked());
+}
+
+#endif // wxHAS_EVENT_BIND
+