본문 바로가기

Development

[WebBrowser] WebBrowser Control Has No Scrollbar in CDHTMLDialog

WebBrowser Control Has No Scrollbar in CDHTMLDialog

modestyz_at_hotmail.com
Date: 01/10/05


Date: 10 Jan 2005 15:17:34 -0800

Please help me out with this problem!

My MFC dialog based app uses CDHTMLDialog class, and it hosts another
WebBrowser control in the same dialog. I want the HTML in Resource
works like a control panel (easier to customize later) and the hosted
WebBrowser control just to show external URL content.

Everything works fine except the hosted content WebBrwoser never shows
scroll bar, even when the page is obvious bigger than it's client
rectangle, neither horizontal nor vertical.

When I google this problem, I found some questions/answsers are all
about to HIDE the vertical scrollbar, none of them is about to show the
scrollbar.

I also tried to change the SCROLL attribute of the loaded document's
body, it doesn't work either:

void CMyBrowserDlg::DocumentCompleteExplorer(LPDISPATCH pDisp, VARIANT*
URL)
{
//to enable the WebBrowser's scrollbar
//supposedly, vertical scrollbar should always display, but it's not
the case in here...
HRESULT hr = S_OK;
CComPtr<IWebBrowser2> pWB;

hr = pDisp->QueryInterface(IID_IWebBrowser2,
reinterpret_cast<void**>(&pWB));

CComPtr<IDispatch> pDocDisp;
hr = pWB->get_Document(&pDocDisp);

if (!pDocDisp == FALSE)
{
CComPtr<IHTMLDocument2> pDoc;
hr = pDocDisp->QueryInterface(IID_IHTMLDocument2,
reinterpret_cast<void **>(&pDoc));

CComPtr<IHTMLElement> pElement;
hr = pDoc->get_body(&pElement);

CComPtr<IHTMLBodyElement> pBodyElement;
hr = pElement->QueryInterface(IID_IHTMLBodyElement,
(void**)&pBodyElement);

if (!pBodyElement == FALSE)
pBodyElement->put_scroll(CComBSTR(L"yes"));

//CComPtr<IHTMLWindow2> pWindow;
//hr = pDoc->get_parentWindow( &pWindow );

//CScrollBar* pIEVSB = m_ieBrowser.GetScrollBarCtrl(SB_VERT);
//if (pIEVSB)//it's ALWAYS NULL!
// pIEVSB->ShowWindow(SW_SHOW);

//pWindow->scrollBy(0, 100); //it can scroll, but no scrollbar shows
up!
        }
}

Please help!

Thanks a lot!

Modesty

'Development' 카테고리의 다른 글

[MFC] 구조도  (0) 2008.12.16
[Development] START 명령을 이용  (0) 2008.12.15
[Win32] GetModuleHandle과 LoadLibrary  (0) 2008.12.03
[역공학] OnlyDbg  (0) 2008.12.01
[역공학] OnlyDbg PlugIn Site  (0) 2008.12.01