Microsoft KB Archive/181677

= FIX: Selecting DocObject Server Menu Disables Internet Explorer's Menu Options =

Article ID: 181677

Article Last Modified on 5/12/2003

-

APPLIES TO

 Microsoft Internet Explorer 4.0 128-Bit Edition Microsoft Internet Explorer 4.01 Service Pack 2 Microsoft Internet Explorer 5.0 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition

 Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q181677

<div class="symptoms_section">

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.

<div class="cause_section">

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.

<div class="resolution_section">

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); }

<div class="status_section">

STATUS
Microsoft 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.

Additional query words: ActiveX documents

Keywords: kbbug kbfix kbie501fix KB181677

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.