+ //
+ // Menubars should be associated with a frame otherwise they are popups
+ //
+ if (m_menuBarFrame != NULL)
+ hFrame = GetWinHwnd(m_menuBarFrame);
+ else
+ hFrame = HWND_DESKTOP;
+ //
+ // Create an empty menu and then fill it with insertions
+ //
+ if ((m_hMenu = ::WinCreateWindow( hFrame
+ ,WC_MENU
+ ,NULL
+ ,MS_ACTIONBAR | WS_SYNCPAINT | WS_VISIBLE
+ ,0L
+ ,0L
+ ,0L
+ ,0L
+ ,hFrame
+ ,HWND_TOP
+ ,FID_MENU
+ ,NULL
+ ,NULL
+ )) == 0)
+ {
+ wxLogLastError(wxT("WinLoadMenu"));
+ }
+ else
+ {
+ size_t nCount = GetMenuCount(), i;
+ wxMenuList::iterator it;
+ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
+ {
+ APIRET rc;
+ ERRORID vError;
+ wxString sError;
+ HWND hSubMenu;
+
+ //
+ // Set the parent and owner of the submenues to be the menubar, not the desktop
+ //
+ hSubMenu = (*it)->m_vMenuData.hwndSubMenu;
+ if (!::WinSetParent((*it)->m_vMenuData.hwndSubMenu, m_hMenu, FALSE))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str());
+ return NULLHANDLE;
+ }
+
+ if (!::WinSetOwner((*it)->m_vMenuData.hwndSubMenu, m_hMenu))
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str());
+ return NULLHANDLE;
+ }
+
+ (*it)->m_vMenuData.iPosition = (SHORT)i;
+
+ rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&(*it)->m_vMenuData, (MPARAM)m_titles[i].wx_str());
+ if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError(wxT("Error inserting or appending a menuitem. Error: %s\n"), sError.c_str());
+ return NULLHANDLE;
+ }
+ }
+ }
+ return m_hMenu;
+} // end of wxMenuBar::Create
+
+// ---------------------------------------------------------------------------
+// wxMenuBar functions to work with the top level submenus
+// ---------------------------------------------------------------------------
+
+//
+// NB: we don't support owner drawn top level items for now, if we do these
+// functions would have to be changed to use wxMenuItem as well
+//
+void wxMenuBar::EnableTop(
+ size_t nPos
+, bool bEnable
+)