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:
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:
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:
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:
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 June 2009 - 09:11 AM

Add Reply



MultiQuote


| 


