BUG: Scroll Bars and Borders Appear in Framesets When You Navigate Again in BeforeNavigate
function loadTOCNode(){}
Article ID |
: |
324419 |
Last Review |
: |
May 12, 2003 |
Revision |
: |
2.0 |
This article was previously published under Q324419
var sectionFilter = "type != 'notice' && type != 'securedata' && type != 'querywords'";
var tocArrow = "/library/images/support/kbgraphics/public/en-us/downarrow.gif";
var depthLimit = 10;
var depth3Limit = 10;
var depth4Limit = 5;
var depth5Limit = 3;
var tocEntryMinimum = 1;
<noscript></noscript>
SYMPTOMS
loadTOCNode(1, 'symptoms');
An empty scroll bar and sometimes a border appear if the following conditions are true:
• |
You display a frameset in an application that hosts the WebBrowser control. -and-
|
• |
You navigate to a frame in the frameset elsewhere in the BeforeNavigate or the BeforeNavigate2 event handler. |
These items should not appear in the frame.
Back to the top
RESOLUTION
loadTOCNode(1, 'resolution');
To work around the problem with the scroll bar, use one of the following methods:
• |
In the HTML source for the frame page, manually add the "auto" or the "no" value to the scroll attribute in the <body> tag. |
• |
Add the scroll attribute dynamically through Dynamic HTML (DHTML). |
• |
Delay the navigation by posting a user-defined message and by performing the navigation in the user-defined message handler. |
To work around the problem with the border, use one of the following methods:
• |
Post a user-defined message, and then perform the navigation in the user-defined message handler. |
• |
Implement the IDocHostUIHandler interface, and then return DOCHOSTUIFLAG_NO3DBORDER in the GetHostInfo method. |
For more information, see the "More Information" section of this article.
Back to the top
STATUS
loadTOCNode(1, 'status');
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Back to the top
MORE INFORMATION
loadTOCNode(1, 'moreinformation');
Steps to Reproduce the Behavior
loadTOCNode(2, 'moreinformation');
NOTE: These steps are written for Microsoft Visual C++ 6.0.
1. |
Use the following code to create the frameset page, and then name the page frameset.htm:
<HTML>
<FRAMESET rows="100%" cols="33%,33%,34%">
<FRAME src="framesetChild.htm" frameborder="0" scrolling="0">
</FRAME>
<FRAME src="framesetChild.htm" frameborder="0" scrolling="0">
</FRAME>
<FRAME src="framesetChild.htm" frameborder="0" scrolling="0">
</FRAME>
</FRAMESET>
</HTML>
|
2. |
Copy frameset.htm to the Web server. |
3. |
Use the following code to create a frame page, and then name the page framesetChild.htm:
<HTML>
<body>
This is a frame<br>
</body>
</HTML>
|
4. |
Copy framesetChild.htm to the Web server. |
5. |
Create a default Microsoft Foundation Classes (MFC) dialog-based application. |
6. |
Right-click the dialog, and then click Insert ActiveX Control. Click Microsoft Web Browser Control. |
7. |
To add a control data member for the WebBrowser control, follow these steps:
a. |
Open the Class Wizard, and then click the Member Variables tab. |
b. |
Make sure that the dialog class is selected in the Class name list. |
c. |
Click IDC_EXPLORER1 (which is the default ID of the WebBrowser control), and then click Add Variable. |
d. |
You receive a message that states that the control has not been inserted into the project. Click OK to add the control to the project. Click OK again to accept the defaults for the CWebBrowser2 class in the Confirm Class dialog box. |
e. |
Name your member variable m_webBrowser, and then click OK. |
f. |
Close the Class Wizard. |
|
8. |
To add the BeforeNavigate2 event handler, follow these steps:
a. |
Open the Class Wizard, and then click the Message Maps tab. |
b. |
Make sure that the dialog class is selected in the Class name list. |
c. |
Click IDC_EXPLORER1 in the Object IDs list, and then click BeforeNavigate2 in the Messages list. |
d. |
Click Add Function to add the handler. |
|
9. |
Add the following code:
void CMFCReproDlg::OnBeforeNavigate2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)
{
static int nCount = 0;
nCount++;
if (nCount == 2) // this should be the navigate for the first frame in frameset
{
IWebBrowser* pWB = NULL;
HRESULT hr = pDisp->QueryInterface(IID_IWebBrowser, (void**)&pWB);
COleVariant ve((long)0);
pWB->Navigate(::SysAllocString(L"http://myserver/mydirectory/framesetChild.htm"), &ve, &ve, &ve, &ve);
*Cancel = VARIANT_TRUE;
}
}
|
10. |
Add the following code to navigate to the frame page in the end of the OnInitDialog function.
BOOL CMFCReproDlg::OnInitDialog()
{
...
m_webBrowser.Navigate("http://myserver/mydirectory/frameset.htm", NULL, NULL, NULL, NULL);
|
11. |
Build the application, and then run it. Notice that the first frame has a scroll bar and a border on the right side. |
Back to the top
Remove the Scroll Bar
loadTOCNode(2, 'moreinformation');
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.
|
• |
Post a user-defined message, and then perform the navigation in the user-defined message handler to delay the navigation.
Add the following code to the header file:
class CMFCReproDlg : public CDialog
{
...
afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam);
};
Add the following code to the implementation file:
#define WM_MYMESSAGE (WM_USER + 1)
BEGIN_MESSAGE_MAP(CMFCReproDlg, CDialog)
//{{AFX_MSG_MAP(CMFCReproDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_MYMESSAGE, OnMyMessage)
END_MESSAGE_MAP()
struct CMyData
{
IWebBrowser2* m_pWB;
BSTR m_pUrl;
};
void CMFCReproDlg::OnBeforeNavigate2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)
{
static int nCount = 0;
nCount++;
if (nCount == 2) // this should be the navigate for the first frame in frameset
{
*Cancel = VARIANT_TRUE;
CMyData *data = new CMyData;
HRESULT hr = pDisp->QueryInterface(IID_IWebBrowser2, (void**)(&data->m_pWB));
data->m_pUrl = ::SysAllocString(L"http://myserver/mydirectory/framesetChild.htm");
PostMessage(WM_MYMESSAGE, (WPARAM)data, 0);
}
}
LRESULT CMFCReproDlg::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
CMyData *data = (CMyData*)wParam;
COleVariant ve((long)0);
data->m_pWB->Navigate(data->m_pUrl, &ve, &ve, &ve, &ve);
delete data;
return 1;
}
|
Back to the top
Remove the Border
loadTOCNode(2, 'moreinformation');
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.
分享到:
相关推荐
例如,`WebBrowser.Navigate()`方法可以用来加载URL,`Document`对象则可以访问和操作网页内容。 3. **JWebBrowser库**: 这个库可能封装了与COM交互的具体细节,为Java开发者提供了一个更友好的API来操作IE。可能...
VB 6.0演示WebBrowser用法制作简单的网页浏览器,主要是以一些WebBrowser.Navigate、WebBrowser.GoBack、WebBrowser.Stop等基本操作函数的用法演示,利用本程序打开和设置默认主页,具体实现如下所示: Private ...
5. `WebBrowser.npk`:可能是一个资源包文件,存储了浏览器所需的特定资源或配置信息。 6. `com.run`:可能是一个启动脚本,用于运行或配置浏览器。 7. `tzl.td`:未知具体用途,可能是一个配置或数据文件。 8. `...
delphi动态 WebBrowser 释放问题.txt var web:TwebBrowser; procedure TForm1.Button1Click(Sender: TObject); begin web:=TWebBrowser.Create(Self); web.ParentWindow:=Self.Handle; web.SetBounds(100,100,...
delphi动态 WebBrowser 释放问题 var web:TwebBrowser; procedure TForm1.Button1Click(Sender: TObject); begin web:=TWebBrowser.Create(Self); web.ParentWindow:=Self.Handle; web.SetBounds(100,100,100,...
WebBrowser 控件 内存溢出 补丁 From Microsoft 在程序中用WebBrowser长时间不停访问...获取补丁的网址,如果不放心请自己去微软下载 http://support.microsoft.com/kb/943510/zh-cn 我这里也把自己获得的补丁给大家
EO.WebBrowser最新版本(v23.4.26)免安装dll.C# 直接引用版本。 EO.WebBrowser,就是给.NET用的Chrome浏览器内核,可以在WinForm中嵌入Chrome浏览器,客户端不用安装浏览器都可以。 无缝集成chrome浏览器引擎和.net...
到NuGet下载官方dll NuGet Gallery | EO.WebBrowser for .NET 16.2.37 https://www.nuget.org/packages/EO.WebBrowser/ 出自 .NET Google 浏览器内核 Eo.Webbrowser | Flyヽ ...http://lfei.org/net-eo-webbrowser/
对于C#开发者,实现Web打印功能时,可以利用ASP.NET框架中的WebBrowser控件或System.Drawing命名空间下的PrintDocument类。WebBrowser控件可以直接嵌入网页,模拟用户交互进行打印;而PrintDocument类则允许在服务器...
首先,我们需要引入两个关键的组件:Microsoft Outlook Object Library 和 Microsoft Internet Controls(也称为Shdocvw.dll)。这两个组件提供了发送电子邮件所需的基本功能。在VB的工具箱中,你可以找到`...
首先声明源码是从其他网站买来的,能不能用自己测试,,,, 后端教程 ...2.导入数据库 全部替换http://xbk0.cn/ 为 你的域名 ...4.后台地址:login/login/mike ...webBrowser clipBoard wx mam mcm 打包完成后结束搭建。
Delphi第三方控件EmbeddedWB,这是一个不错的浏览器控件,比Delphi自带的Webbrowser要强悍很多 ============================================================= Version 14.70.0 - 02.10.2010 - by smot =========...
将webbrowser(其实不用webbrowser只给一个网址也行)中的内容保存为mht(和浏览器的网页另存为功能一样)文件,同时支持页面全屏截图(就是不管页面多长多宽自动截整个页面)。 默认保存为tif格式(应CSDN一名网友...
webbrowser.open(url) ``` 6. **自动化工具**: 自动化工具如Selenium可以模拟用户行为,包括批量打开网页。这对于自动化测试和数据抓取特别有用。 总的来说,批量打开网页程序是一种实用的技巧,可以帮助用户...
1. **加载WebBrowser控件**:在VBA编辑器中,通过引用Microsoft WebBrowser Control 6.0 (SP6)来启用WebBrowser控件的支持。 2. **导航至目标网页**:利用WebBrowser对象的Navigate属性,加载需要填写表单的网页...
1、ctk框架在ubuntu编译 2、生成后库文件so 3、c++ 插件式开发资料 4、开发环境需要安装gcc 文件比较大,需要下载以下3个压缩包,放在同一个目录解压合并为一个文件 ... ... ...
1、ctk框架在ubuntu编译 2、生成后库文件so 3、c++ 插件式开发资料 4、开发环境需要安装gcc 文件比较大,需要下载以下3个压缩包,放在同一个目录解压合并为一个文件 ... ... ...
1、ctk框架在ubuntu编译 2、生成后库文件so 3、c++ 插件式开发资料 4、开发环境需要安装gcc 文件比较大,需要下载以下3个压缩包,放在同一个目录解压合并为一个文件 ... ... ...
- 登录成功后,可以使用WebBrowser控件(在Windows Forms中)或WebView2(在WPF中)来显示网页。 - 设置WebBrowser或WebView2的Url属性为自定义网页的地址。 8. **错误处理**: - 添加适当的异常处理,捕获可能...
解压密码:123 安装说明:...EO必需品对象。Total是为。...该集合包含以下内容。EO。互联网浏览器Chrome浏览器引擎是基于程序部分,这完全是编码在。.......在Wpf应用程序中使用的一整套优秀的Wpf控件