Hi, I have this code for some custom events in a webbrowser I'm making. The events are meant to be for when the user carries out certain actions, here are the actions:
Mouse Enters a link (HTMLElement)
Mouse Exits a link (HTMLElement)
Mouse Clicks a link (HTMLElement)
Mouse Enters an image (HTMLElement)
Mouse Exits an image (HTMLElement)
Here is the code:
CODE
Private Sub nav() Handles Me.DocumentCompleted
Dim link As HtmlElement
Dim links As HtmlElementCollection = Me.Document.Links
For Each link In links
link.AttachEventHandler("onclick", AddressOf LinkClicked)
link.AttachEventHandler("onmouseover", AddressOf OnMouseEnter)
link.AttachEventHandler("onmouseleave", AddressOf OnMouseLeave)
Next
Dim picture As HtmlElement
Dim pictures As HtmlElementCollection = Me.Document.Images
For Each picture In pictures
picture.AttachEventHandler("mouseon", AddressOf OnMouseEnter)
picture.AttachEventHandler("mouseon", AddressOf OnMouseLeave)
Next
end sub
Here is the code to handle the link events:
CODE
Private Sub OnMouseEnter(ByVal sender As Object, ByVal e As EventArgs)
CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ContextMenuStrip = Form1.LinkContextMenu
End Sub
Private Sub OnMouseLeave(ByVal sender As Object, ByVal e As EventArgs)
CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).IsWebBrowserContextMenuEnabled = False
CType(Form1.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ContextMenuStrip = Form1.MyContextMenu
End Sub
Private Sub LinkClicked(ByVal sender As Object, ByVal e As EventArgs)
'complicated stuff which is irrelevant
end sub
Here is the code to handle the Image events:
CODE
Private Sub OnMouseEnter(ByVal sender As Object, ByVal e As EventArgs)
'Set a different context menu
End Sub
Private Sub OnMouseLeave(ByVal sender As Object, ByVal e As EventArgs)
'Set a different context menu
End Sub
Here is my problem: I have the event handler with the same name for both my Picture event and my Link events. How can I change my code so that the same function is carried out as I want, but the names for each of the events are different?
Here is the error which I am yielding:
CODE
Error 3 'Private Sub OnMouseEnter(sender As Object, e As System.EventArgs)' has multiple definitions with identical signatures. C:\Users\Josh The Great\Documents\Visual Studio 2008\Projects\Net Browser\Net Browser\Forms\Form1.vb 2164 17 Net Browser
This post has been edited by Jack Eagles1: 10 Jun, 2009 - 09:11 AM