FIX: Selecting DocObject Server Menu Disables Internet Explorer's Menu Options (181677)
The information in this article applies to:
- Microsoft Internet Explorer (Programming) 4.0
- Microsoft Internet Explorer (Programming) 4.01
- Microsoft Internet Explorer (Programming) 5
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2b
- Microsoft Visual C++, 32-bit Professional Edition 4.2b
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
This article was previously published under Q181677 SYMPTOMS
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.
CAUSE
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.
RESOLUTION
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);
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Internet Explorer 5.01.
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbBug kbfix kbie501fix KB181677 |
---|
|