|
-
Nov 3rd, 2003, 03:00 PM
#1
Thread Starter
Frenzied Member
Newwindow event with webbrowser object? :s
Hi guys i am trying to make a popup detection with the webbrowser object in vb.net ... tried it the old vb6 way but that doesnt seem to work.. tried loads of stuff .. either i get an error in the new window event or i dont and get no beforenavigate2 event call 
VB Code:
_frmmain.popupdetection = e.ppDisp
this is as far as i have gotten without it crashing
-
Nov 3rd, 2003, 03:19 PM
#2
i wrote an article a few months ago on this and a fix i made , it's on the CodeProject, the link is...Extending the axWebbrowser control events.
you can handle all the events that the browser would through the SHDocVw.DWebBrowserEvents_Event , the basis of the article is this....
VB Code:
Private WithEvents doc As SHDocVw.DWebBrowserEvents_Event
'/// doc will handle all the events for brweb now...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim b As Object = brWeb.Application
doc = DirectCast(b, SHDocVw.WebBrowser_V1) '///set doc as the active handler for brweb's events.
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
brWeb.Navigate("http://google.com") '///lets navigate to a website.
End Sub
Private Sub doc_BeforeNavigate(ByVal URL As String, ByVal Flags As Integer, ByVal TargetFrameName As String, ByRef PostData As Object, ByVal Headers As String, ByRef Cancel As Boolean) Handles doc.BeforeNavigate
MessageBox.Show(URL) '/// check that before navigate now works.
End Sub
Private Sub doc_StatusTextChange(ByVal [Text] As String) Handles doc.StatusTextChange
Label1.Text = Text '///show the status text in a label.
End Sub
Private Sub doc_TitleChange(ByVal [Text] As String) Handles doc.TitleChange
MyBase.Text = Text '/// set the form's caption to the current url
End Sub
but if you want to visit the article, you could always vote for me
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Nov 3rd, 2003, 03:35 PM
#3
Thread Starter
Frenzied Member
thanks for the help.. still stuck though 
this is what i have
in a usercontroll :
VB Code:
Private Sub ie_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles ie.NewWindow2
Try
e.ppDisp = _frmmain.popupdetection
e.cancel = True
Catch
MsgBox(Err.Description)
End Try
End Sub
in frmmain (alias _frmmain):
VB Code:
Private WithEvents popupdoc As SHDocVw.DWebBrowserEvents_Event
Private Sub frmmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim b As Object = popupdetection.Application
_frmmain.popupdetection = New AxSHDocVw.AxWebBrowser
popupdoc = DirectCast(b, SHDocVw.WebBrowser_V1)
end sub
Private Sub popupdoc_BeforeNavigate(ByVal URL As String, ByVal Flags As Integer, ByVal TargetFrameName As String, ByRef PostData As Object, ByVal Headers As String, ByRef Cancel As Boolean) Handles popupdoc.BeforeNavigate
MsgBox(URL)
End Sub
still doesnt fire a thing
-
Nov 3rd, 2003, 03:49 PM
#4
you need to replace this.....
Private Sub ie_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles ie.NewWindow2
with this....
VB Code:
Private Sub popupdoc_NewWindow(ByVal URL As String, ByVal Flags As Integer, ByVal TargetFrameName As String, ByRef PostData As Object, ByVal Headers As String, ByRef Processed As Boolean) Handles doc.NewWindow
MessageBox.Show(URL & " " & TargetFrameName)
End Sub
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Nov 3rd, 2003, 05:03 PM
#5
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|