怎样消除CWebBrowser2控件边框?

狼夹势凶 IT男  2005-08-25 02:13:03
用CWebBrowser2控件四周有一个立体边框。。。
看上去好像网页凹进了框里。。。
有无有方法把这个边框去掉呢?
期待中..........
...全文
807 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
蒋晟 2005-08-26
Remove the Scroll Bar
To remove the scroll bar, use one of following methods: • Add scroll attribute value of "auto" or "no" to the framesetChild.htm page as follows:<HTML>
<body scroll="auto">
This is a frame<br>
</body>
</HTML>


• Dynamically add the scroll attribute value of "auto" or "no" in your code through DHTML as follows: #include <mshtml.h>
// For brevity, this code adds the attribute to all documents.
void CMFCReproDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL)
{
HRESULT hr = S_OK;
IWebBrowser2* pWB = NULL;

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

IDispatch* pDocDisp = NULL;
hr = pWB->get_Document(&pDocDisp);

if (pDocDisp)
{
VARIANT v;
VariantInit(&v);

IHTMLDocument2* pDoc = NULL;
hr = pDocDisp->QueryInterface(IID_IHTMLDocument2, reinterpret_cast<void **>(&pDoc));

IHTMLElement* pElement = NULL;
hr = pDoc->get_body(&pElement);

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

if (pBodyElement)
{
pBodyElement->put_scroll(::SysAllocString(L"auto"));
pBodyElement->Release();
}
pElement->Release();
pDoc->Release();
pDocDisp->Release();
}
pWB->Release();
}


NOTE: These first two options only remove the scroll bar. The border may still persist.
Remove the Border
To remove the borders, use one of following methods: • Post a user-defined message, and then perform the navigation in the user-defined message handler.
• Follow the steps in Microsoft Knowledge Base article Q196835 to provide the custom control site in which you can add the IDocHostUIHandler interface. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
196835 (http://support.microsoft.com/kb/196835/EN-US/) HOWTO: Override the MFC Default Control Containment
After you implement all the functions, you must add DOCHOSTUIFLAG_NO3DBORDER to the DOCHOSTUIINFO stucture in the dwFlags field for the GetHostInfo method. It is beyond the scope of this article to provide the steps to implement IDocHostUIHandler.
NOTE: The border problem does not appear in an Active Template Library (ATL) container because the ATL class, CAxHostWindow, already implements the IDocHostUIHandler interface. By default, CAxHostWindow enables this flag.
回复
蒋晟 2005-08-26
Remove the Scroll Bar
To remove the scroll bar, use one of following methods: • Add scroll attribute value of "auto" or "no" to the framesetChild.htm page as follows:<HTML>
<body scroll="auto">
This is a frame<br>
</body>
</HTML>


• Dynamically add the scroll attribute value of "auto" or "no" in your code through DHTML as follows: #include <mshtml.h>
// For brevity, this code adds the attribute to all documents.
void CMFCReproDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL)
{
HRESULT hr = S_OK;
IWebBrowser2* pWB = NULL;

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

IDispatch* pDocDisp = NULL;
hr = pWB->get_Document(&pDocDisp);

if (pDocDisp)
{
VARIANT v;
VariantInit(&v);

IHTMLDocument2* pDoc = NULL;
hr = pDocDisp->QueryInterface(IID_IHTMLDocument2, reinterpret_cast<void **>(&pDoc));

IHTMLElement* pElement = NULL;
hr = pDoc->get_body(&pElement);

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

if (pBodyElement)
{
pBodyElement->put_scroll(::SysAllocString(L"auto"));
pBodyElement->Release();
}
pElement->Release();
pDoc->Release();
pDocDisp->Release();
}
pWB->Release();
}


NOTE: These first two options only remove the scroll bar. The border may still persist.
Remove the Border
To remove the borders, use one of following methods: • Post a user-defined message, and then perform the navigation in the user-defined message handler.
• Follow the steps in Microsoft Knowledge Base article Q196835 to provide the custom control site in which you can add the IDocHostUIHandler interface. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
196835 (http://support.microsoft.com/kb/196835/EN-US/) HOWTO: Override the MFC Default Control Containment
After you implement all the functions, you must add DOCHOSTUIFLAG_NO3DBORDER to the DOCHOSTUIINFO stucture in the dwFlags field for the GetHostInfo method. It is beyond the scope of this article to provide the steps to implement IDocHostUIHandler.
NOTE: The border problem does not appear in an Active Template Library (ATL) container because the ATL class, CAxHostWindow, already implements the IDocHostUIHandler interface. By default, CAxHostWindow enables this flag.
回复
goodboyws 2005-08-25
边框其实是网页显示的
将网页改为以下格式即可消除边框
<body leftmargin="0" topmargin="0" style="width: 100%; border-width=0; border-style:none">
<a href="http://www.puzzlepirates.com.cn/" target=_blank>哈哈</a></body>
回复
发帖
界面
创建于2007-09-28

1.5w+

社区成员

VC/MFC 界面
申请成为版主
帖子事件
创建了帖子
2005-08-25 02:13
社区公告
暂无公告