+static wxMenu *CopyMenu (wxMenu *menu)
+{
+ wxMenu *menucopy = new wxMenu ();
+ wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
+ while (node)
+ {
+ wxMenuItem *item = node->GetData();
+ int itemid = item->GetId();
+ wxString text = item->GetText();
+ text.Replace(wxT("_"), wxT("&"));
+ wxMenu *submenu = item->GetSubMenu();
+ if (!submenu)
+ {
+ wxMenuItem* itemcopy = new wxMenuItem(menucopy,
+ itemid, text,
+ menu->GetHelpString(itemid));
+ itemcopy->SetBitmap(item->GetBitmap());
+ itemcopy->SetCheckable(item->IsCheckable());
+ menucopy->Append(itemcopy);
+ }
+ else
+ menucopy->Append (itemid, text, CopyMenu(submenu),
+ menu->GetHelpString(itemid));
+
+ node = node->GetNext();
+ }
+
+ return menucopy;
+}
+