BUG: Cannot Navigate Away from MFC Active Document in IE4Last reviewed: December 10, 1997Article ID: Q177551 |
The information in this article applies to:
SYMPTOMSWhen you load a file into Internet Explorer 4.0 (IE4) that is associated with an Active Document server that is written in MFC, you cannot navigate away from the currently loaded page. IE4 will appear to start loading the next page, the progress bar indicator will fill part way, and the IE logo will begin spinning. However, IE4 will remain in this state indefinitely, until shut down.
CAUSEThis is caused by a fault in MFC's implementation of IOleCommandTarget::QueryStatus. MFC's QueryStatus implementation incorrectly specifies that unknown command IDs are currently supported but disabled. IE4 uses an undocumented command-group command to determine whether the Active Document (formerly called "ActiveX Document") server can be deactivated. Since MFC responds incorrectly that the command-group command is supported and disabled, the Active Document server is never unloaded.
RESOLUTIONAs a workaround, you must override CDocObjectServer and COleCmdUI to provide the correct functionality. (See the MORE INFORMATION section for instructions on how to do this.)
STATUSMicrosoft 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.
MORE INFORMATIONThe following information describes the steps to work around the bug that is stated above. The AxDocFix sample referenced below demonstrates this workaround. To work around this bug, follow these steps for a basic AppWizard-created Active Document server:
COleCmdUI state(rgCmds, cCmds, pguidCmdGroup); to this CMyOleCmdUI state(rgCmds, cCmds, pguidCmdGroup); CMyOleCmdUI is the COleCmdUI-derived class that you will create in step 10.
#include "MyDocObjectServer.h"
return new CMyDocObjectServer(this, pDocSite);
class CMyOleCmdUI : public COleCmdUI { public: CMyOleCmdUI(OLECMD* rgCmds, ULONG cCmds, const GUID* pGroup) : COleCmdUI(rgCmds, cCmds, pGroup) { } virtual BOOL DoUpdate(CCmdTarget* pTarget, BOOL bDisableIfNoHandler); };
#include "MyOleCmdUI.h"
if (bDisableIfNoHandler && !m_bEnableChanged) { AFX_CMDHANDLERINFO info; info.pTarget = NULL; bResult = pTarget->OnCmdMsg(m_nID, CN_COMMAND, this, &info); Enable(bResult); if (bResult || m_bEnableChanged) m_rgCmds[m_nIndex].cmdf |= OLECMDF_SUPPORTED; else m_rgCmds[m_nIndex].cmdf &= ~OLECMDF_SUPPORTED; } to this: if (bDisableIfNoHandler && !m_bEnableChanged) { AFX_CMDHANDLERINFO info; info.pTarget = NULL; bResult = pTarget->OnCmdMsg(m_nID, CN_COMMAND, this, &info); if (bResult || m_bEnableChanged) m_rgCmds[m_nIndex].cmdf |= OLECMDF_SUPPORTED; else m_rgCmds[m_nIndex].cmdf &= ~OLECMDF_SUPPORTED; Enable(bResult); } This changes the order in which Enable is called.
#include "afxconv.h" and add this include statement to the CMyOleCmdUI implementation file:
#include <afxpriv.h> Afxpriv.h is needed for the proper implementation of CMyOleCmdUI's command routing mechanism in DoUpdate(). NOTE: Code that requires Afxpriv.h is not guaranteed to work correctly in future versions of Visual C++ and with future versions of the MFC DLL. However, because this is the only workaround to the bug described in this article, use of Afxpriv.h cannot be avoided. Once a future version of MFC has fixed this bug, this workaround should be removed from your code. A default MFC Active Document server that has these fixes applied is available for download from the Microsoft Software Library:
~ AxDocFix.exe (size: 50500 bytes)For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online Services(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Scott Roberts, Microsoft Corporation
Keywords : AXSDKDocObjects Technology : kbInetDev kbole Version : WINDOWS:4.0; WINNT:4.2,4.2b,5.0 Platform : WINDOWS winnt Issue type : kbbug kbfile |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |