鼠标单击事件不在webbrowser控件上工作 [英] Mouse Click Event Not working on webbrowser control

查看:68
本文介绍了鼠标单击事件不在webbrowser控件上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用浏览器,我需要在vb.net上检索鼠标点击的坐标,如果我使用了webbrowser控件,我试图在该webbrowser上有一个透明的面板,这个面板总是有控件颜色,即使我将BGcolor更改为透明,请帮助

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

推荐答案

虽然您无法直接从浏览器控件获取鼠标单击事件,但您可以处理来自HtmlDocument当前显示在浏览器中以获取此信息。



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.

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


Click事件不起作用,因为它是由网页本身处理的。你无法在网页浏览器控件中触发click事件。



在顶部使用透明控件并不会显示下面的webbrowser控件因为控件不会在其他控件下绘制字符。 Z顺序中最顶层的控件OWNS占据了它所占用的像素。没有其他控件可以在他们不拥有的一组像素中绘制自己。
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.


非常感谢,你做了我的一天:)
Thanks A lot, you made my day :)


这篇关于鼠标单击事件不在webbrowser控件上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆