如何在CHTMLVIEW类的ONNEWWINDOWS2的消息响应函数中获取新窗口的URL? 如何在CHTMLVIEW类的ONNEWWINDOWS2的消息响应函数中获取新窗口的URL? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Knowledge Base HOWTO: Cause Navigation to Occur in Same WebBrowser WindowPSS ID Number: Q185538Article Last Modified on 07-20-2001--------------------------------------------------------------------------------The information in this article applies to: Microsoft Internet Explorer (Programming) 4.0, 4.01, 5, 5.5--------------------------------------------------------------------------------SummaryWhen hosting the Internet Explorer 4.x or later WebBrowser control in a Visual Basic application, you may want to have the navigation always occur in your application and not other Internet Explorer windows. If you handle the NewWindow2 event and set the Cancel flag equal to True, navigation is canceled completely. Since NewWindow2 does not provide you with the URL to navigate to as the Internet Explorer 3.x NewWindow event did, there doesn't appear to be any way to have the navigation occur in the same window. Fortunately, Internet Explorer 4.x or later provide the WebBrowser_V1 object for compatibility with Internet Explorer 3.x. Using the WebBrowser_V1 object, you can have your application receive events from version 3.x, 4.x, and 5.x. That means that you can handle the version 3.x NewWindow event and then have the navigation occur in the current window. More InformationIn order to implement this functionality in your Visual Basic application, follow these step: Create a form with a WebBrowser control on it. In the declarations section of that form, add the following: Dim WithEvents Web_V1 as SHDocVwCtl.WebBrowser_V1 This will declare a WebBrowser_V1 variable that can receive events WebBrowser_V1 provides you with the NewWindow event. In the Form_Load event, add the following: Set Web_V1 = WebBrowser1.Object WebBrowser1.Navigate2 "http://www.microsoft.com/" This sets the WebBrowser_V1 object to the existing Internet Explorer WebBrowser object. After the NewWindow2 event fires, the Web_V1_NewWindow event will fire with the linked URL as one of its input arguments. Remember not to set Cancel to True in NewWindow2. Also, set the Processed variable to True in the NewWindow event handler so that a new instance of Internet Explorer will not be created. The following code shows this event handler and the code necessary to navigate within the current window: Private Sub Web_V1_NewWindow(ByVal URL As String, _ ByVal Flags As Long, _ ByVal TargetFrameName As String, _ PostData As Variant, _ ByVal Headers As String, _ Processed As Boolean) Processed = True WebBrowser1.Navigate URL End Sub Right-click a link and select "Open in New Window" and you will find the link will still open inside your WebBrowser Control.Please note that Internet Explorer does not fire a NewWindow or NewWindow2 event when the user presses CTRL+N or points to New under the File menu and clicks Window. ReferencesFor additional information, please see the following article in the Microsoft Knowledge Base: Q184876 HOWTO: Use the WebBrowser Control NewWindow2 Event For more information, see the MSDN Online Web Workshop: http://msdn.microsoft.com/workshop/(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Scott Roberts, Microsoft Corporation Additional query words: NewWindow NewWindow2 Keywords: kbIE400 kbie401 kbWebBrowser kbGrpDSInet kbie500 kbDSupport kbie550 Issue Type: kbhowto Technology: kbIEsearch kbAudDeveloper kbSDKIESearch kbIE500Search kbSDKIE400 kbSDKIE401 kbSDKIE500 kbSDKIE550 kbIE550Search --------------------------------------------------------------------------------Send feedback to Microsoft© 2002-2003 Microsoft Corporation. All rights reserved. 我本意是自己利用CHTMLVIEW写一个小浏览器,如果连接在新窗口打开,那么可以截取它然后在指定的CHTMLVIEW中打开;不然会在IE中打开。 位图保存下来是翻转的!!!!!!!!!!!!!!!!如何正过来 按键映射的addin程序 关于调用命令行程序的问题 问:关于使用一个程序控制另一个程序界面的问题 怎样得到所有的子窗口? STL 中链表的删除操作 【CSDN】【请问这段话说得对不对,为什么,请说明理由】 >>>> 哪里能下载到 吴晓军的 2.13 汉字系统?? vc中报表怎么弄 各位大哥给评评理,我有什么错?在线..... 求助地址类型的转换 100分在线急救: 有关端口编程
--------------------------------------------------------------------------------
The information in this article applies to: Microsoft Internet Explorer (Programming) 4.0, 4.01, 5, 5.5--------------------------------------------------------------------------------
Summary
When hosting the Internet Explorer 4.x or later WebBrowser control in a Visual Basic application, you may want to have the navigation always occur in your application and not other Internet Explorer windows. If you handle the NewWindow2 event and set the Cancel flag equal to True, navigation is canceled completely. Since NewWindow2 does not provide you with the URL to navigate to as the Internet Explorer 3.x NewWindow event did, there doesn't appear to be any way to have the navigation occur in the same window. Fortunately, Internet Explorer 4.x or later provide the WebBrowser_V1 object for compatibility with Internet Explorer 3.x. Using the WebBrowser_V1 object, you can have your application receive events from version 3.x, 4.x, and 5.x. That means that you can handle the version 3.x NewWindow event and then have the navigation occur in the current window. More Information
In order to implement this functionality in your Visual Basic application, follow these step: Create a form with a WebBrowser control on it.
In the declarations section of that form, add the following:
Dim WithEvents Web_V1 as SHDocVwCtl.WebBrowser_V1
This will declare a WebBrowser_V1 variable that can receive events WebBrowser_V1 provides you with the NewWindow event.
In the Form_Load event, add the following:
Set Web_V1 = WebBrowser1.Object
WebBrowser1.Navigate2 "http://www.microsoft.com/"
This sets the WebBrowser_V1 object to the existing Internet Explorer WebBrowser object.
After the NewWindow2 event fires, the Web_V1_NewWindow event will fire with the linked URL as one of its input arguments. Remember not to set Cancel to True in NewWindow2. Also, set the Processed variable to True in the NewWindow event handler so that a new instance of Internet Explorer will not be created. The following code shows this event handler and the code necessary to navigate within the current window:
Private Sub Web_V1_NewWindow(ByVal URL As String, _
ByVal Flags As Long, _
ByVal TargetFrameName As String, _
PostData As Variant, _
ByVal Headers As String, _
Processed As Boolean)
Processed = True
WebBrowser1.Navigate URL
End Sub
Right-click a link and select "Open in New Window" and you will find the link will still open inside your WebBrowser Control.Please note that Internet Explorer does not fire a NewWindow or NewWindow2 event when the user presses CTRL+N or points to New under the File menu and clicks Window. References
For additional information, please see the following article in the Microsoft Knowledge Base: Q184876 HOWTO: Use the WebBrowser Control NewWindow2 Event
For more information, see the MSDN Online Web Workshop:
http://msdn.microsoft.com/workshop/
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Scott Roberts, Microsoft Corporation Additional query words: NewWindow NewWindow2 Keywords: kbIE400 kbie401 kbWebBrowser kbGrpDSInet kbie500 kbDSupport kbie550
Issue Type: kbhowto
Technology: kbIEsearch kbAudDeveloper kbSDKIESearch kbIE500Search kbSDKIE400 kbSDKIE401 kbSDKIE500 kbSDKIE550 kbIE550Search --------------------------------------------------------------------------------Send feedback to Microsoft© 2002-2003 Microsoft Corporation. All rights reserved.