// // Menu- and menuband- related utility functions // #include "local.h" #include "dochost.h" // this goes away when the split is done **and** dochost goes away /*---------------------------------------------------------- Purpose: Replace the contents of hmenuDst with hmenuSrc. Note any submenus in hmenuDst will be deleted. Call Menu_RemoveAllSubMenus if you don't want this to happen. */ void Menu_Replace(HMENU hmenuDst, HMENU hmenuSrc) { int cItems = GetMenuItemCount(hmenuDst); int i; for (i=0; i= cmenuFrame || IS_VALID_HANDLE(miiFrame.hSubMenu, MENU)); // The browser may have a menu that was not merged into // the shared menu because the object put one in with // the same name. Have we hit this case? Check by comparing // sz and szFrame if (mii.hSubMenu == miiFrame.hSubMenu || 0 == StrCmp(sz, szFrame)) { bMatched = TRUE; break; } else { if (iFrame >= cmenuFrame) { break; } iFrame++; } } // Is this one of our menus? mlitem.bObject = (mii.hSubMenu == miiFrame.hSubMenu) ? FALSE:TRUE; if (bMatched) { iFrame++; } else { iFrame = iSaveFrame; } DSA_SetItem(_hdsa, i, &mlitem); } } } /*---------------------------------------------------------- Purpose: Adds the given hmenu to the list. */ void CMenuList::AddMenu(HMENU hmenu) { ASSERT(NULL == hmenu || IS_VALID_HANDLE(hmenu, MENU)); if (_hdsa && hmenu) { MLITEM mlitem; mlitem.hmenu = hmenu; mlitem.bObject = TRUE; DSA_AppendItem(_hdsa, &mlitem); } } /*---------------------------------------------------------- Purpose: Removes the given hmenu from the list. */ void CMenuList::RemoveMenu(HMENU hmenu) { ASSERT(NULL == hmenu || IS_VALID_HANDLE(hmenu, MENU)); if (_hdsa && hmenu) { int i = DSA_GetItemCount(_hdsa) - 1; for (; i >= 0; i--) { MLITEM * pmlitem = (MLITEM *)DSA_GetItemPtr(_hdsa, i); ASSERT(pmlitem); if (hmenu == pmlitem->hmenu) { DSA_DeleteItem(_hdsa, i); break; } } } } /*---------------------------------------------------------- Purpose: Returns TRUE if the given hmenu belongs to the object. */ BOOL CMenuList::IsObjectMenu(HMENU hmenu) { BOOL bRet = FALSE; ASSERT(NULL == hmenu || IS_VALID_HANDLE(hmenu, MENU)); if (_hdsa && hmenu) { int i; for (i = 0; i < DSA_GetItemCount(_hdsa); i++) { MLITEM * pmlitem = (MLITEM *)DSA_GetItemPtr(_hdsa, i); ASSERT(pmlitem); if (hmenu == pmlitem->hmenu) { bRet = pmlitem->bObject; break; } } } return bRet; } #ifdef DEBUG void CMenuList::Dump(LPCTSTR pszMsg) { if (IsFlagSet(g_dwDumpFlags, DF_DEBUGMENU)) { TraceMsg(TF_ALWAYS, "CMenuList: Dumping menus for %#08x %s", (LPVOID)this, pszMsg); if (_hdsa) { int i; for (i = 0; i < DSA_GetItemCount(_hdsa); i++) { MLITEM * pmlitem = (MLITEM *)DSA_GetItemPtr(_hdsa, i); ASSERT(pmlitem); TraceMsg(TF_ALWAYS, " [%d] = %x", i, pmlitem->hmenu); } } } } #endif #endif