Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get rid of the scrollbars in a WebBrowser control?

How to get rid of the scrollbars in a WebBrowser control?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    panoramix
    wrote on last edited by
    #1

    Hi, I'm using a WebBrowser control inside a CView class. I've used the ClassWizard to encapsulate the control's functionality, but although I've used SetWidth() and SetHeight() to set the right values, I can't get rid of the vertical scrollbar on the right. SetResizeable(FALSE) returns a funny message, and none of the CWnd scrollbar functions seem to have any effect. Any help will be greatly appreciated.

    T 1 Reply Last reply
    0
    • P panoramix

      Hi, I'm using a WebBrowser control inside a CView class. I've used the ClassWizard to encapsulate the control's functionality, but although I've used SetWidth() and SetHeight() to set the right values, I can't get rid of the vertical scrollbar on the right. SetResizeable(FALSE) returns a funny message, and none of the CWnd scrollbar functions seem to have any effect. Any help will be greatly appreciated.

      T Offline
      T Offline
      TBK
      wrote on last edited by
      #2

      This can be done with the IDocHostUIHandler interface that you must implement in your container (CView derived class). Look at GetHostInfo and returning with docHostUIFlagSCROLL_NO flag set. In ATL support for this interface is built in. You can look at the implementation of CAxHostWindow for an example implementation. A description of some of this can be found in ATL Internals.

      P 1 Reply Last reply
      0
      • T TBK

        This can be done with the IDocHostUIHandler interface that you must implement in your container (CView derived class). Look at GetHostInfo and returning with docHostUIFlagSCROLL_NO flag set. In ATL support for this interface is built in. You can look at the implementation of CAxHostWindow for an example implementation. A description of some of this can be found in ATL Internals.

        P Offline
        P Offline
        panoramix
        wrote on last edited by
        #3

        void CDaTestView::OnInitialUpdate() { CView::OnInitialUpdate(); m_WebBrowserCtrl.SetLeft(0); m_WebBrowserCtrl.SetTop(0); m_WebBrowserCtrl.SetWidth(156); m_WebBrowserCtrl.SetHeight(92); if(m_WebBrowserCtrl.EnableScrollBar(SB_BOTH, ESB_DISABLE_BOTH) == TRUE) TRACE("Cannot disable scrollbars!"); m_WebBrowserCtrl.ShowScrollBar(SB_BOTH, FALSE); // Initialize the first URL. COleVariant noArg; m_WebBrowserCtrl.Navigate("file://D:/PROJECTS/MosaicLCD/default.html",&noArg,&noArg,&noArg,&noArg); LPDISPATCH pDisp = NULL; IDocHostUIHandler *pHostUIHandler = NULL; pDisp = m_WebBrowserCtrl.GetDocument(); ASSERT(pDisp); pDisp->QueryInterface(IID_IDocHostUIHandler, (LPVOID*)&pHostUIHandler); ASSERT(pHostUIHandler); if(pHostUIHandler) { DOCHOSTUIINFO *pInfo = NULL; pHostUIHandler->GetHostInfo(pInfo); if(pInfo) { if(((pInfo->dwFlags) & DOCHOSTUIFLAG_SCROLL_NO) == (pInfo->dwFlags)) TRACE("Scrolling enabled"); else TRACE("Scrolling disabled"); } } if(pHostUIHandler) pHostUIHandler->Release(); // release document's command target if(pDisp) pDisp->Release(); // release document's dispatch interface } I'm creating the m_WebBrowserCtrl in CDaTestView::OnCreate() but I get an assertion in the line pDisp = m_WebBrowserCtrl.GetDocument(); ASSERT(pDisp); pDisp is NULL! Any idea why? Is there something else wrong with this code? Thanks in advance

        T 1 Reply Last reply
        0
        • P panoramix

          void CDaTestView::OnInitialUpdate() { CView::OnInitialUpdate(); m_WebBrowserCtrl.SetLeft(0); m_WebBrowserCtrl.SetTop(0); m_WebBrowserCtrl.SetWidth(156); m_WebBrowserCtrl.SetHeight(92); if(m_WebBrowserCtrl.EnableScrollBar(SB_BOTH, ESB_DISABLE_BOTH) == TRUE) TRACE("Cannot disable scrollbars!"); m_WebBrowserCtrl.ShowScrollBar(SB_BOTH, FALSE); // Initialize the first URL. COleVariant noArg; m_WebBrowserCtrl.Navigate("file://D:/PROJECTS/MosaicLCD/default.html",&noArg,&noArg,&noArg,&noArg); LPDISPATCH pDisp = NULL; IDocHostUIHandler *pHostUIHandler = NULL; pDisp = m_WebBrowserCtrl.GetDocument(); ASSERT(pDisp); pDisp->QueryInterface(IID_IDocHostUIHandler, (LPVOID*)&pHostUIHandler); ASSERT(pHostUIHandler); if(pHostUIHandler) { DOCHOSTUIINFO *pInfo = NULL; pHostUIHandler->GetHostInfo(pInfo); if(pInfo) { if(((pInfo->dwFlags) & DOCHOSTUIFLAG_SCROLL_NO) == (pInfo->dwFlags)) TRACE("Scrolling enabled"); else TRACE("Scrolling disabled"); } } if(pHostUIHandler) pHostUIHandler->Release(); // release document's command target if(pDisp) pDisp->Release(); // release document's dispatch interface } I'm creating the m_WebBrowserCtrl in CDaTestView::OnCreate() but I get an assertion in the line pDisp = m_WebBrowserCtrl.GetDocument(); ASSERT(pDisp); pDisp is NULL! Any idea why? Is there something else wrong with this code? Thanks in advance

          T Offline
          T Offline
          TBK
          wrote on last edited by
          #4

          You must wait for the DocumentComplete event from the Web browser control before you can get the document. Also you must implement the IDocHostUIHandler interface. The Web browser control will call your GetHostInfo method. You might be able to find some example code for this interface using MFC.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups