// Create an event handler for a wxButton click event void MyFrame::OnButtonClick(wxCommandEvent& event) { int eventType = event.GetEventType(); // get the event type identifier if (eventType == wxEVT_BUTTON) { // handle the button click event } }
// Create an event handler for a wxMenuItem selection event void MyFrame::OnMenuItemSelected(wxCommandEvent& event) { int eventType = event.GetEventType(); // get the event type identifier if (eventType == wxEVT_MENU) { int menuItemId = event.GetId(); // get the menu item identifier if (menuItemId == ID_MENU_ITEM_OPEN_FILE) { // handle the "Open File" menu item selection event } } }In this example, the GetEventType function is used to determine if the command event that triggered the event handler was a wxEVT_MENU event. We then use the GetId function to get the identifier of the menu item that was selected. This allows us to perform specific actions based on the selected menu item. Package Library: wxWidgets