Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I'm Working on a browser , and I need to retrieve the coordinate of mouse click on vb.net if I used webbrowser control , I tried to have a transparent Panel over that webbrowser , this panel always has control color , even when I change the BGcolor to transparent ,, Please help
Posted
Comments
Sergey Alexandrovich Kryukov 30-Apr-13 18:52pm    
I think it does work. Anyway, "not working" is not informative...
—SA

While you can not get a mouse click event directly from the browser control, you can handle various events from the HtmlDocument currently displayed in the browser to get this information.

VB
Public Class Form1

   Dim WithEvents doc As HtmlDocument

   Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
      If WebBrowser1.Url.Equals(e.Url) Then
         doc = WebBrowser1.Document
      End If
   End Sub

   Private Sub doc_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles doc.Click
      Debug.WriteLine(e.MousePosition)
      Debug.WriteLine(e.ClientMousePosition)
   End Sub

End Class
 
Share this answer
 
The Click event doesn't work because it's handled by the web page itself. You cannot get the click event to fire in a web browser control.

Using a "transparent" control over the top doesn't show you the webbrowser control underneath because controls do not paint themsleves under other controls. The top-most control in the Z-order OWNS the pixels it occupies. No other controls will draw themselves in a group of pixels that they do not own.
 
Share this answer
 
Thanks A lot, you made my day :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900