博客原文:http://blog.sina.com.cn/s/blog_537bf93c01009own.html
网上搜了一下,提问题的人不少,找到合适的答案不容易。我把自己曾经总结的贴出来,希望能够对需要的朋友有用。
HRESULT hr;
IDispatch *pDisp = GetHtmlDocument();
IHTMLDocument2 *pDocument = NULL;
IHTMLElement* pEl;
IHTMLBodyElement *pBodyEl;
hr = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDocument);
if(SUCCEEDED(pDocument->get_body(&pEl)))
{
if(SUCCEEDED(pEl->QueryInterface(IID_IHTMLBodyElement, (void**)&pBodyEl)))
{
pBodyEl->put_scroll(L"no");//去滚动条
}
IHTMLStyle *phtmlStyle;
pEl->get_style(&phtmlStyle);
if(phtmlStyle != NULL)
{
phtmlStyle->put_overflow(L"hidden");
phtmlStyle->put_border(L"none");// 去除边框
phtmlStyle->Release();
pEl->Release();
}
}
///
博客原文:http://hi.baidu.com/dotfire/blog/item/1995e23de73feeeb3c6d977a.html
VC++ 怎样去掉webbrowser2 的滚动条
LPDISPATCH lpidsp=m_WebBrowser2.GetDocument();
ASSERT(lpidsp);
IHTMLDocument2 *pDoc=NULL;
HRESULT hr;
hr=lpidsp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc);
ASSERT(SUCCEEDED(hr));
ASSERT(pDoc);
IHTMLElement *pBody=NULL;
hr=pDoc->get_body(&pBody);
ASSERT(SUCCEEDED(hr));
ASSERT(pBody);
IHTMLElement *pElement=NULL;
hr=pBody->QueryInterface(IID_IHTMLElement,(void**)&pElement);
ASSERT(SUCCEEDED(hr));
ASSERT(pElement);
CComBSTR v("SCROLL");
CComVariant vv="no";
pElement->setAttribute(v,vv,0);