Results 1 to 5 of 5

Thread: Newwindow event with webbrowser object? :s

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    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:
    1. _frmmain.popupdetection = e.ppDisp
    this is as far as i have gotten without it crashing
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    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:
    1. Private WithEvents doc As SHDocVw.DWebBrowserEvents_Event
    2.      '/// doc will handle all the events for brweb now...
    3.      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.          Dim b As Object = brWeb.Application
    5.          doc = DirectCast(b, SHDocVw.WebBrowser_V1) '///set doc as the active handler for brweb's events.
    6.      End Sub
    7.  
    8.      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    9.          brWeb.Navigate("http://google.com") '///lets navigate to a website.
    10.      End Sub
    11.  
    12.      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
    13.          MessageBox.Show(URL) '/// check that before navigate now works.
    14.      End Sub
    15.  
    16.      Private Sub doc_StatusTextChange(ByVal [Text] As String) Handles doc.StatusTextChange
    17.          Label1.Text = Text '///show the status text in a label.
    18.      End Sub
    19.  
    20.      Private Sub doc_TitleChange(ByVal [Text] As String) Handles doc.TitleChange
    21.          MyBase.Text = Text '/// set the form's caption to the current url
    22.      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]

  3. #3

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    thanks for the help.. still stuck though

    this is what i have

    in a usercontroll :
    VB Code:
    1. Private Sub ie_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles ie.NewWindow2
    2.         Try
    3.             e.ppDisp = _frmmain.popupdetection
    4.             e.cancel = True
    5.         Catch
    6.             MsgBox(Err.Description)
    7.         End Try
    8.     End Sub

    in frmmain (alias _frmmain):
    VB Code:
    1. Private WithEvents popupdoc As SHDocVw.DWebBrowserEvents_Event
    2.  
    3.  
    4.     Private Sub frmmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         Dim b As Object = popupdetection.Application
    6.       _frmmain.popupdetection = New AxSHDocVw.AxWebBrowser
    7.         popupdoc = DirectCast(b, SHDocVw.WebBrowser_V1)
    8. end sub
    9.    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
    10.         MsgBox(URL)
    11.     End Sub

    still doesnt fire a thing
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    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:
    1. 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
    2.         MessageBox.Show(URL & "     " & TargetFrameName)
    3.     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]

  5. #5

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    hmm power failure in my block

    will try the code now


    edit:

    LIKE A GLOVE.... better then the origional way thank u 5 stars it is

    edit 2 :
    No star rating here.. doing the other site then
    Last edited by Ultimasnake; Nov 3rd, 2003 at 05:07 PM.
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width