void COleIPFrameWnd::DestroySharedMenu() { if (m_hSharedMenu == NULL) { ASSERT(m_hOleMenu == NULL); return; } // get in-place menu to be unmerged (must be same as during activation) HMENU hMenu = GetInPlaceMenu(); if (hMenu == NULL) return; // remove our menu popups from the shared menu AfxUnmergeMenus(CMenu::FromHandle(m_hSharedMenu), CMenu::FromHandle(hMenu)); // allow container to remove its items from the menu ASSERT(m_lpFrame != NULL); VERIFY(m_lpFrame->RemoveMenus(m_hSharedMenu) == S_OK); // now destroy the menu ::DestroyMenu(m_hSharedMenu); m_hSharedMenu = NULL; #ifndef _MAC if (m_hOleMenu != NULL) { VERIFY(::OleDestroyMenuDescriptor(m_hOleMenu) == S_OK); m_hOleMenu = NULL; } #endif }
BOOL COleIPFrameWnd::BuildSharedMenu() { HMENU hMenu = GetInPlaceMenu(); // create shared menu ASSERT(m_hSharedMenu == NULL); if ((m_hSharedMenu = ::CreateMenu()) == NULL) return FALSE; // start out by getting menu from container memset(&m_menuWidths, 0, sizeof m_menuWidths); if (m_lpFrame->InsertMenus(m_hSharedMenu, &m_menuWidths) != S_OK) { ::DestroyMenu(m_hSharedMenu); m_hSharedMenu = NULL; return FALSE; } // only copy the popups if there is a menu loaded if (hMenu == NULL) return TRUE; BOOL bMergeHelpMenus = FALSE; // special case - we're embedded in a docobject server that's in a docobject container if (m_menuWidths.width[5] != 0) bMergeHelpMenus = TRUE; // insert our menu popups amongst the container menus m_hMenuHelpPopup = AfxMergeMenus(m_hSharedMenu, hMenu, &m_menuWidths.width[0], 1, bMergeHelpMenus); // finally create the special OLE menu descriptor m_hOleMenu = ::OleCreateMenuDescriptor(m_hSharedMenu, &m_menuWidths); return m_hOleMenu != NULL; }
BOOL COleIPFrameWnd::BuildSharedMenu() { HMENU hMenu = GetInPlaceMenu(); // create shared menu ASSERT(m_hSharedMenu == NULL); if ((m_hSharedMenu = ::CreateMenu()) == NULL) return FALSE; // start out by getting menu from container memset(&m_menuWidths, 0, sizeof m_menuWidths); if (m_lpFrame->InsertMenus(m_hSharedMenu, &m_menuWidths) != S_OK) { ::DestroyMenu(m_hSharedMenu); m_hSharedMenu = NULL; return FALSE; } // container shouldn't touch these ASSERT(m_menuWidths.width[1] == 0); ASSERT(m_menuWidths.width[3] == 0); ASSERT(m_menuWidths.width[5] == 0); // only copy the popups if there is a menu loaded if (hMenu == NULL) return TRUE; // insert our menu popups amongst the container menus AfxMergeMenus(CMenu::FromHandle(m_hSharedMenu), CMenu::FromHandle(hMenu), &m_menuWidths.width[0], 1); #ifndef _MAC // finally create the special OLE menu descriptor m_hOleMenu = ::OleCreateMenuDescriptor(m_hSharedMenu, &m_menuWidths); return m_hOleMenu != NULL; #else return TRUE; #endif }