+ 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;
+ }