943,608 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1317
  • VB.NET RSS
Nov 21st, 2008
0

AttachEventHandler issues

Expand Post »
i have a web browser control which i have added a status strip.

I can get the status strip to display the clicked link fine but i would like it to display the link target when the mouse is hover over the link but i cannot get it to work!

My code is below - any help is greatly appreciated!

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub mainWebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles mainWebBrowser.DocumentCompleted
  2.  
  3.  
  4.  
  5. Dim Olink As HtmlElement
  6. Dim Elem As HtmlElementCollection = mainWebBrowser.Document.Links
  7.  
  8. 'check the link that has been clicked
  9. For Each Olink In Elem
  10. 'call the procedure to check if this is a valid link
  11. Olink.AttachEventHandler("onclick", AddressOf LinkClicked)
  12. Olink.AttachEventHandler("mousemove", AddressOf LinkStatus)
  13. Next
  14.  
  15. End Sub
  16.  
  17.  
  18.  
  19. Private Sub LinkClicked()
  20.  
  21. Accepted = False
  22.  
  23. Dim link As HtmlElement = mainWebBrowser.Document.ActiveElement
  24. Dim url As String = link.GetAttribute("href")
  25.  
  26. Call CheckLinkClicked(url)
  27.  
  28. 'Call SearchValue()
  29.  
  30. If Accepted = True Then
  31. mainWebBrowser.Navigate(url)
  32. ToolStripStatusLabel2.Text = url & "(Allowed)"
  33. Else
  34. bCancel = True
  35. ToolStripStatusLabel2.Text = url & "(not allowed)"
  36. MsgBox("That is not an allowed URL" & Chr(13) & Chr(10) & "If this is wrong, then someone needs to enter this site into the allowed list!")
  37. End If
  38.  
  39. urlTextBox.Text = mainWebBrowser.Url.ToString
  40.  
  41. End Sub
  42.  
  43.  
  44. Sub LinkStatus()
  45.  
  46. Accepted = False
  47.  
  48. Dim link As HtmlElement = mainWebBrowser.Document.ActiveElement
  49. Dim url As String = link.GetAttribute("href")
  50.  
  51. Call CheckLinkClicked(url)
  52.  
  53. 'Call SearchValue()
  54.  
  55. If Accepted = True Then
  56.  
  57. ToolStripStatusLabel2.Text = url & "(Allowed)"
  58. Else
  59.  
  60. ToolStripStatusLabel2.Text = url & "(not allowed)"
  61.  
  62. End If
  63. End Sub
Reputation Points: 22
Solved Threads: 9
Junior Poster
ninjaimp is offline Offline
129 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: detecting delete on row in datagridview and updating dataset
Next Thread in VB.NET Forum Timeline: [HELP] Please Check this thread its urgent!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC