BUG: Selecting DocObject Server Menu Disables IE's Menu Options

Last reviewed: March 19, 1998
Article ID: Q181677
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), versions 4.0, 4.01
  • The Microsoft Foundation Classes (MFC) included with:

    - Microsoft Visual C++, 32-bit Editions, versions 4.2, 4.2b, 5.0

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

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: ActiveX documents
Keywords : MfcOLE AXSDKDocObjects
Technology : kbInetDev kbole kbmfc
Version : win95:4.0,4.01; WINNT:4.1,4.2,5.0
Platform : Win95 winnt
Issue type : kbbug
Solution Type : kbpending


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 19, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.