Article ID: 181677
Article Last Modified on 5/12/2003
/*
========================================================================
Name: FindMenu
Purpose : Helper function for finding a submenu within a menu
Arguments: hFindMenu - HMENU to look for
hSearchMenu - HMENU to search in
========================================================================
*/
BOOL FindMenu (HMENU hFindMenu, HMENU hSearchMenu)
{
BOOL bRet = FALSE;
// get number of items in hSearchMenu
int iMenuItemCount = GetMenuItemCount (hSearchMenu);
// loop through hSearchMenu to find hFindMenu
for (int iCntr=0; iCntr<iMenuItemCount; iCntr++)
{
// get each submenu in hSearchMenu
HMENU hSubMenu = GetSubMenu (hSearchMenu, iCntr);
if (hSubMenu)
{
// if we find a match, get out
if (hFindMenu == hSubMenu)
break;
// recurse into FindMenu looking for hFindMenu in each submenu
if (FindMenu (hFindMenu, hSubMenu))
break;
}
}
// match found
if (iCntr != iMenuItemCount)
bRet = TRUE;
return bRet;
}
void CInPlaceFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex,
BOOL bSysMenu)
{
COleServerDoc* pDoc = (COleServerDoc*)GetActiveDocument();
ASSERT (pDoc);
// if we're created as a docobject
if (pDoc->IsDocObject())
{
// if submenu is not found in in-place menu, return
if (FALSE == FindMenu (pPopupMenu->GetSafeHmenu(),
GetInPlaceMenu()))
return;
}
COleDocIPFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
}
Additional query words: ActiveX documents
Keywords: kbbug kbfix kbie501fix KB181677