+// recursive search for item by id
+wxMenuItem* wxMenu::FindItem(
+ int nItemId
+, ULONG hItem
+, wxMenu** ppItemMenu
+) const
+{
+ if ( ppItemMenu )
+ *ppItemMenu = NULL;
+
+ wxMenuItem* pItem = NULL;
+
+ for ( wxMenuItemList::Node *node = m_items.GetFirst();
+ node && !pItem;
+ node = node->GetNext() )
+ {
+ pItem = node->GetData();
+
+ if ( pItem->GetId() == nItemId && pItem->m_vMenuData.hItem == hItem)
+ {
+ if ( ppItemMenu )
+ *ppItemMenu = (wxMenu *)this;
+ }
+ else if ( pItem->IsSubMenu() )
+ {
+ pItem = pItem->GetSubMenu()->FindItem(nItemId, hItem, ppItemMenu);
+ }
+ else
+ {
+ // don't exit the loop
+ pItem = NULL;
+ }
+ }
+ return pItem;
+} // end of wxMenu::FindItem
+