- int i;
-/*
- // See remarks in ::~wxMenu() method
- // BEWARE - this may interfere with MDI fixes, so
- // may need to remove
- int N = 0 ;
-
- if (m_menuBarFrame && ((m_menuBarFrame->GetWindowStyleFlag() & wxSDI) == wxSDI))
- {
- if (menu)
- N = GetMenuItemCount(menu) ;
- for (i = N-1; i >= 0; i--)
- RemoveMenu(menu, i, MF_BYPOSITION);
- }
-*/
- for (i = 0; i < m_menuCount; i++)
- {
- delete m_menus[i];
- }
- delete[] m_menus;
- delete[] m_titles;
-
-/* Don't destroy menu here, in case we're MDI and
- need to do some shuffling with VALID menu handles.
- if (menu)
- DestroyMenu(menu);
- m_hMenu = 0;
-*/
+ if ( hasNoTitle )
+ {
+ if ( !label.IsEmpty() )
+ {
+ if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING,
+ (unsigned)idMenuTitle, m_title) ||
+ !::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) )
+ {
+ wxLogLastError(wxT("InsertMenu"));
+ }
+ }
+ }
+ else
+ {
+ if ( label.IsEmpty() )
+ {
+ // remove the title and the separator after it
+ if ( !RemoveMenu(hMenu, 0, MF_BYPOSITION) ||
+ !RemoveMenu(hMenu, 0, MF_BYPOSITION) )
+ {
+ wxLogLastError(wxT("RemoveMenu"));
+ }
+ }
+ else
+ {
+ // modify the title
+#ifdef __WXWINCE__
+ MENUITEMINFO info;
+ wxZeroMemory(info);
+ info.cbSize = sizeof(info);
+ info.fMask = MIIM_TYPE;
+ info.fType = MFT_STRING;
+ info.cch = m_title.Length();
+ info.dwTypeData = (LPTSTR) m_title.c_str();
+ if ( !SetMenuItemInfo(hMenu, 0, TRUE, & info) )
+ {
+ wxLogLastError(wxT("SetMenuItemInfo"));
+ }
+#else
+ if ( !ModifyMenu(hMenu, 0u,
+ MF_BYPOSITION | MF_STRING,
+ (unsigned)idMenuTitle, m_title) )
+ {
+ wxLogLastError(wxT("ModifyMenu"));
+ }
+#endif
+ }
+ }
+
+#ifdef __WIN32__
+ // put the title string in bold face
+ if ( !m_title.IsEmpty() )
+ {
+ SetDefaultMenuItem(GetHmenu(), (UINT)idMenuTitle);
+ }
+#endif // Win32