1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
Public Sub New()
Me.InitializeComponent()
' Cast to WebBrowser, so that we can subscribe to the NewWindow2 event
AddHandler DirectCast(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance, SHDocVw.WebBrowser).NewWindow3, AddressOf browses_NewWindow3
AddHandler DirectCast(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance, SHDocVw.WebBrowser).NewWindow2, AddressOf browses_NewWindow2
End Sub
Private Sub browses_NewWindow3(ByRef ppDisp As Object, ByRef Cancel As Boolean, ByVal dwFlags As UInteger, ByVal bstrUrlContext As String, ByVal bstrUrl As String)
' There's no cancel on this event, but setting ppDisp prevents a new IE window
ppDisp = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
' Unfortunately, the ppDisp does not navigate to the new url. We'll do that manually.
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(bstrUrl)
End Sub
Private Sub browses_NewWindow2(ByRef ppDisp As Object, ByRef Cancel As Boolean)
' Set ppDisp to the instance of IE we want used
ppDisp = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
End Sub |
Partager