VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,412 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,594 people online right now. Registration is fast and FREE... Join Now!




Webbrowser Extended Navigating Event

 

Webbrowser Extended Navigating Event, EEK! An Error!

Jack Eagles1

3 Jul, 2009 - 05:36 AM
Post #1

D.I.C Head
**

Joined: 10 Dec, 2008
Posts: 249



Thanked: 5 times
My Contributions
Hi, I have this code to attach a new navigating event to a custom webbrowser control. Here it is:

CODE

    Protected Friend Sub OnNewWindowExtended(ByVal Url As String, ByRef Cancel As Boolean, ByVal Flags As NWMF, ByVal UrlContext As String)
        Dim e As WebBrowserNewWindowExtendedEventArgs = New WebBrowserNewWindowExtendedEventArgs(Url, UrlContext, Flags)
        RaiseEvent NewWindowExtended(Me, e)
        Cancel = e.Cancel
    End Sub


However, on the (Me, E) code, I get an error, specifically:
Value of type 'Net_Browser.browse.WebBrowserNewWindowExtendedEventArgs' cannot be converted to 'Net_Browser.browse.WebBrowserNewWindowExtendedEventHandler'.


I do not know what is happening here, as I have used this code on previous projects before. Can anyone help me?


User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 06:53 AM
Post #2

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Well, you're declaring a WebBrowserNewWindowExtendedEventArgs but you're trying to use it like a WebBrowserNewWindowExtendedEventHandler. Do you have the following event handlers and delegates defined in your code?
CODE

'This new event will fire when the page is navigating
Public Delegate Sub WebBrowserNavigatingExtendedEventHandler(ByVal sender As Object, ByVal e As WebBrowserNavigatingExtendedEventArgs)
Public Event NavigatingExtended As WebBrowserNavigatingExtendedEventHandler

'This event will fire when a new window is about to be opened
Public Delegate Sub WebBrowserNewWindowExtendedEventHandler(ByVal sender As Object, ByVal e As WebBrowserNewWindowExtendedEventArgs)
Public Event NewWindowExtended As WebBrowserNewWindowExtendedEventHandler

User is offlineProfile CardPM
+Quote Post

Jack Eagles1

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 07:56 AM
Post #3

D.I.C Head
**

Joined: 10 Dec, 2008
Posts: 249



Thanked: 5 times
My Contributions
Yes, I do have those declarations in my code.

PS: Do you personally know Thomas Maxwell?
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 08:00 AM
Post #4

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
If it's not too much can you show all the code from the class/module that this code is in?
User is offlineProfile CardPM
+Quote Post

Jack Eagles1

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 08:25 AM
Post #5

D.I.C Head
**

Joined: 10 Dec, 2008
Posts: 249



Thanked: 5 times
My Contributions
Sure, Here:

CODE

Public Class Browse
Inherits Webbrowser
    Public Delegate Sub WebBrowserNavigatingExtendedEventHandler(ByVal sender As Object, ByVal e As browse.WebBrowserNavigatingExtendedEventHandler)
    Public Event NavigatingExtended As WebBrowserNavigatingExtendedEventHandler
    'This event will fire when a new window is about to be opened
    Public Delegate Sub WebBrowserNewWindowExtendedEventHandler(ByVal sender As Object, ByVal e As browse.WebBrowserNewWindowExtendedEventHandler)
    Public Event NewWindowExtended As WebBrowserNewWindowExtendedEventHandler
    Private Sub nav() Handles Me.DocumentCompleted
        Dim pic As HtmlElement
        Dim pics As HtmlElementCollection = Me.Document.Images
        For Each pic In pics
            pic.AttachEventHandler("OnMousover", AddressOf OnEnter)
        Next
        Me.AllowNavigation = False
        Form1.AllowNav.Start()
        Dim link As HtmlElement
        Dim links As HtmlElementCollection = Me.Document.Links
        For Each link In links
            link.AttachEventHandler("onclick", AddressOf LinkClicked)
        Next
        Form1.ComboBox1.Text = CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
        Form1.Text = "Net Browser | " + CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.Host()
        Form1.ComboBox2.Items.Add(Me.Url.ToString)
        Form1.Button7.Enabled = False
        Me.IsWebBrowserContextMenuEnabled = False
        Me.ContextMenuStrip = Form1.MyContextMenu
        Dim des As String = CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
        Dim position As Integer

        If des.Length > 30 Then
            Do Until des.Length < 30
                position = des.Length - 1
                des = des.Remove(position, 1)
            Loop
            Form1.TabControl1.SelectedTab.Text = des + "..."
        Else
            Form1.TabControl1.SelectedTab.Text = des
        End If
        GetFavIcon()
        If CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ReadyState Then
            Form1.ToolStripProgressBar1.Visible = False
        End If
        Form1.webtimer2.Start()
    End Sub
    Dim href As String
    Private Sub OnEnter(ByVal sender As Object, ByVal e As EventArgs)
        MsgBox("Picure")
    End Sub
    Private Sub LinkClicked(ByVal sender As Object, ByVal e As EventArgs)
        Me.AllowNavigation = True
        href = Me.Document.ActiveElement.GetAttribute("href")
        If href.ToUpper.Contains(".wmv".ToUpper) Then
            Dim a As Windows.Forms.DialogResult = MsgBox("Do you want to play this file using media player, [Yes] or download it? [No]", MessageBoxButtons.YesNo, "Confirm")
            If a = Windows.Forms.DialogResult.Yes Then
                Me.AllowNavigation = False
                Form1.AllowNav.Start()
            Else
                Me.AllowNavigation = False
                Form1.DownloadTimer.Start()
                Me.Navigate(My.Settings.Homepage)
            End If
        ElseIf checklink() = True Then
            Me.AllowNavigation = False
            Form1.DownloadTimer.Start()
            Me.Navigate(My.Settings.Homepage)
        Else
            Me.Navigate(href)
        End If
    End Sub
    Public Function allownav()
        Me.AllowNavigation = True
    End Function
    Private Function checklink() As Boolean
        For Each item In My.Settings.LinkTypes
            If href.Contains(item) Then
                Form1.TextBox6.Text = item.ToString
                Return True
            Else
                Return False
            End If
        Next
    End Function

    Protected Friend Sub OnNavigatingExtended(ByVal Url As String, ByVal Frame As String, ByVal Postdata As Byte(), ByVal Headers As String, ByRef Cancel As Boolean)
        Dim e As WebBrowserNavigatingExtendedEventArgs = New WebBrowserNavigatingExtendedEventArgs(Url, Frame, Postdata, Headers)
        RaiseEvent NavigatingExtended(Me, e)
        Cancel = e.Cancel
    End Sub

    Protected Friend Sub OnNewWindowExtended(ByVal Url As String, ByRef Cancel As Boolean, ByVal Flags As NWMF, ByVal UrlContext As String)
        Dim e As WebBrowserNewWindowExtendedEventArgs = New WebBrowserNewWindowExtendedEventArgs(Url, UrlContext, Flags)
        RaiseEvent NewWindowExtended(Me, e)
        Cancel = e.Cancel
    End Sub


User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 08:29 AM
Post #6

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Your problem lies here

CODE

    Public Delegate Sub WebBrowserNavigatingExtendedEventHandler(ByVal sender As Object, ByVal e As browse.WebBrowserNavigatingExtendedEventHandler)
    Public Event NavigatingExtended As WebBrowserNavigatingExtendedEventHandler
    'This event will fire when a new window is about to be opened
    Public Delegate Sub WebBrowserNewWindowExtendedEventHandler(ByVal sender As Object, ByVal e As browse.WebBrowserNewWindowExtendedEventHandler)


In both e is of type WebBrowserNavigatingExtendedEventHandler and if you look at what I posted earlier e is of type WebBrowserNavigatingExtendedEventArgs, so when you're trying to call it with the way you're doing it it's yelling at you. Do you have a class WebBrowserNavigatingExtendedEventArgs? If not then take a look at this.

Hope that helps smile.gif
User is offlineProfile CardPM
+Quote Post

Jack Eagles1

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 08:52 AM
Post #7

D.I.C Head
**

Joined: 10 Dec, 2008
Posts: 249



Thanked: 5 times
My Contributions
Thanks for that code, But now I obtain this error:

Inherits ExtendedWebBrowser

Error 19 'browse' cannot inherit from class 'Module1.ExtendedWebBrowser' because it expands the access of the base class outside the assembly

User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 08:59 AM
Post #8

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Can you show the new code now. I know the code I linked to works, now we just need to get it to work with what you're doing
User is offlineProfile CardPM
+Quote Post

Jack Eagles1

RE: Webbrowser Extended Navigating Event

3 Jul, 2009 - 09:13 AM
Post #9

D.I.C Head
**

Joined: 10 Dec, 2008
Posts: 249



Thanked: 5 times
My Contributions
I cant show the whole of my code (around 1000 pgs) but I will try to give you a better idea of how it is formed


CODE


Imports Statements

Class Form1

'Loads of stuff here, mainly functions, and subs.

End Class


Class Browse

Inherits AdvancedWebbrowser 'Where I am getting the error

My Functions & Events for the webbrowser

End Class


This post has been edited by Jack Eagles1: 3 Jul, 2009 - 09:14 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 11:11PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month