- m_eventHandler = this;
- m_menuCount = N;
- m_menus = Menus;
- m_titles = new wxString[N];
- int i;
- for ( i = 0; i < N; i++ )
- m_titles[i] = Titles[i];
- m_menuBarFrame = NULL;
- for (i = 0; i < N; i++)
- m_menus[i]->m_menuBar = (wxMenuBar *) this;
-
- m_hMenu = 0;
+ bool hasNoTitle = m_title.IsEmpty();
+ m_title = label;
+
+ HMENU hMenu = GetHmenu();
+
+ 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
+ if ( !ModifyMenu(hMenu, 0u,
+ MF_BYPOSITION | MF_STRING,
+ (unsigned)idMenuTitle, m_title) )
+ {
+ wxLogLastError(wxT("ModifyMenu"));
+ }
+ }
+ }
+
+#ifdef __WIN32__
+ // put the title string in bold face
+ if ( !m_title.IsEmpty() )
+ {
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STATE;
+ mii.fState = MFS_DEFAULT;
+
+ if ( !SetMenuItemInfo(hMenu, (unsigned)idMenuTitle, FALSE, &mii) )
+ {
+ wxLogLastError(wxT("SetMenuItemInfo"));
+ }
+ }
+#endif // Win32