+void MyFrame::OnFindMenuItem(wxCommandEvent& WXUNUSED(event))
+{
+ wxMenuBar *mbar = GetMenuBar();
+ size_t count = mbar->GetMenuCount();
+
+ wxCHECK_RET( count, _T("no last menu?") );
+
+ wxString label = wxGetTextFromUser
+ (
+ _T("Enter label to search for: "),
+ _T("Find menu item"),
+ _T(""),
+ this
+ );
+
+ if ( !label.empty() )
+ {
+ size_t menuindex = 0;
+ int index = wxNOT_FOUND;
+
+ for (menuindex = 0; (menuindex < count) && (index == wxNOT_FOUND); ++menuindex)
+ {
+ index = mbar->FindMenuItem(mbar->GetMenu(menuindex)->GetTitle(), label);
+ }
+ if (index == wxNOT_FOUND)
+ {
+ wxLogWarning(wxT("No menu item with label '%s'"), label.c_str());
+ }
+ else
+ {
+ wxLogMessage(wxT("Menu item %d in menu %d has label '%s'"),
+ index, menuindex, label.c_str());
+ }
+ }
+}
+