BUG: WebBrowser Control Destroyed When Hidden

Last reviewed: March 10, 1998
Article ID: Q182111
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), versions 4.0, 4.01
  • The Microsoft Foundation Classes (MFC)
  • Internet Client SDK, versions 4.0, 4.01

SYMPTOMS

The Microsoft WebBrowser control is used in a Microsoft Foundation Class (MFC) application and, following the dynamic creation of the control or call to ShowWindow(SW_HIDE), results in the control's methods not functioning or a debug assertion in Winocc.cpp.

CAUSE

 If the WebBrowser control is created dynamically without specifying the
WS_VISIBLE window style, or if the control's ShowWindow(SW_HIDE) method is called, this results in a call to the control's IOleControl::DoVerb() method with the OLEVERB_HIDE verb. This in turn causes the instance of Internet Explorer to be destroyed, preventing further access to the control's methods, or if built with a debug configuration, the application asserts when CWnd methods are called for the control.

RESOLUTION

Specify the WS_VISIBLE window style when dynamically creating a WebBrowser control and do not call the control's ShowWindow(SW_HIDE) method.

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.

MORE INFORMATION

If you need to hide the WebBrowser control, call the Windows SDK ShowWindow() API directly.

Use the following code to hide the control:

   ::ShowWindow( m_Control.GetSafeHwnd(), SW_HIDE );

Use the following code to show the control:

   ::ShowWindow( m_Control.GetSafeHwnd(), SW_SHOW );

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Mark Davis, Microsoft Corporation
Keywords          : AXSDKWebBrowser
Technology        : kbInetDev internet ole
Version           : WINDOWS:4.0,4.01; WINNT:
Platform          : WINDOWS winnt
Hardware          : x86
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 10, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.