- if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING,
- (UINT)m_menus[i]->GetHMenu(),
- m_titles[i]) )
+ 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].c_str());
+ if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)