yidabu 2007-2-8 18:24
使用你自己的浏览器打开新窗口
使用你自己的浏览器打开新窗口
知识若不分享 实在没有意义 http://www.yidabu.com 20070208
If you trap the NewWindow2 event for the WebBrowser control, you can stop all new windows opening, like this:
Private Sub AxWebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2 e.cancel = True End Sub
Alternatively you could instantiate an InternetExplorer object and pass the handle to that, in this way you can trap what they do in InternetExplorer too.
Code: Dim WithEvents ieChildBrowser As SHDocVw.InternetExplorer Private Sub AxWebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2 ieChildBrowser = New SHDocVw.InternetExplorer() ieChildBrowser.RegisterAsBrowser = True e.ppDisp = ieChildBrowser End Sub(知识若不分享 实在没有意义 http://www.yidabu.com)
Now you can trap the DownloadBegin event, cut out the URL they were going to, close the instance of IE, then Navigate2 in your own WebBrowser.
Code: Private Sub ieChildBrowser_DownloadBegin(ByVal sender As Object, ByVal e As System.EventArgs) Handles ieChildBrowser.DownloadBegin Dim strURL As String strURL = ieChildBrowser.Document.URL ieChildBrowser.Quit() ieChildBrowser = Nothing AxWebBrowser1.Navigate2(strURL) End Sub But I guess the first is simpler as it just stops them being able to do it at all.
(lastupdate:20070208 最新文章请访问http://www.yidabu.com)
关于一大步成功社区:yidabu.com提倡在交流中学习,在分享中提高收集感兴趣的知识,写下心得,通过网络与别人一起分享理解一点就实践一步,收获什么就分享什么,成功就是这样一点点一步步累积起来的网络只是一个工具,只有自己身心提高才是实实在在的。d-programming-language-china.org为大家提供一个学习交流各种知识的平台