FIX: WebBrowser Control in CFormView Does Not Repaint Properly

Last reviewed: January 19, 1998
Article ID: Q179421
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), versions 3.0, 3.01, 3.02
  • Microsoft ActiveX SDK, version 1.0
  • The Microsoft Foundation Classes (MFC) included with:

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

SYMPTOMS

When you resize the WebBrowser control inside a CFormView, it may not repaint correctly.

You may experience the scroll bars not being redrawn.

CAUSE

The WebBrowser control does not handle WM_PAINT messages correctly when it is being resized.

RESOLUTION

When the WebBrowser control is resized, update the client area of the WebBrowser control by calling UpdateWindow().

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Microsoft Internet Explorer 4.0.

MORE INFORMATION

The following code shows how the WebBrowser control would normally be resized when the client window is resized. The call to UpdateWindow() causes a WM_PAINT message to be sent directly to the window of the control.

   // CMyFormView is derived from CFormView.
   // m_browser is a CWnd-derived class that wraps the webbrowser control.
   void CMyFormView::OnSize(UINT nType, int cx, int cy)
   {
      CFormView::OnSize(nType, cx, cy);
      // Ensure m_browser has valid HWND before doing anything
      if ( m_browser.GetSafeHwnd() )
      {
         // Resize WebBrowser control to fill the client area
         m_browser.MoveWindow(0, 0, cx, cy);
         // Force processing of WM_PAINT
         m_browser.UpdateWindow();
      }
   }


Additional query words: web browser shdocvw.dll
Keywords : AXSDKWebBrowser
Technology : kbInetDev ole
Version : WINDOWS:1.0,3.0,3.01,3.02; WINNT:4.2,4.2b,5.0
Platform : WINDOWS winnt
Issue type : kbbug
Solution Type : kbfix


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: January 19, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.