BUG: Selecting DocObject Server Menu Disables IE's Menu OptionsID: Q181677
|
When an Active Document (DocObject) server is loaded into Internet Explorer (IE) 4.0x, and a pop-up menu that is owned by the DocObject server is selected, Internet Explorer's menu options are disabled.
The Microsoft Foundation Classes (MFC) enables and disables menu options in its WM_INITMENUPOPUP message handler. Menu items that do not have a handler function are disabled. This is fine for menu options that are owned by the DocObject server. The problem is Internet Explorer sends a WM_INITMENUPOPUP message to the DocObject server even for menus that it does not own. This is a bug in Internet Explorer 4.0x.
A workaround is to override the WM_INITMENUPOPUP message handler in the
COleDocIPFrameWnd-derived class(CInPlaceFrame) and verify that it is a menu
owned by the DocObject server before calling the base class implementation:
/*
========================================================================
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);
}
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Additional query words: ActiveX documents
Keywords : kbole kbIE400bug kbIE401bug kbMFC kbVC kbIE500bug
Version :
Platform :
Issue type : kbbug
Last Reviewed: April 9, 1999