WEBBROWSER onclick
场景:为什么WebBrowser中Document的onclick事件引发很多有关问题
为什么WebBrowser中Document的onclick事件引发很多问题?
我在VB里成功拦截了document的onclick事件后,出现了所有鼠标事件(如右键、选择)失效的问题,不知什么原因?莫非是因为document的onclick事件为非托管造成的?
------解决方案--------------------
不懂,是不是还需要CallWindowProc()
------解决方案--------------------
答案是什么
是obj.returnValue = True造成的
为什么WebBrowser中Document的onclick事件引发很多问题?
- VB.NET code
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.WebBrowser1.Navigate("http://www.baidu.com") End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted Dim doc As mshtml.HTMLDocument = Me.WebBrowser1.Document.DomDocument Dim docevents As mshtml.HTMLDocumentEvents2_Event = DirectCast(doc, mshtml.HTMLDocumentEvents2_Event) AddHandler docevents.onclick, AddressOf Me.Doc_onclick End Sub Private Function Doc_onclick(ByVal obj As mshtml.IHTMLEventObj) As Boolean Debug.Print(obj.x) obj.returnValue = True Return True End Function End Class
我在VB里成功拦截了document的onclick事件后,出现了所有鼠标事件(如右键、选择)失效的问题,不知什么原因?莫非是因为document的onclick事件为非托管造成的?
------解决方案--------------------
不懂,是不是还需要CallWindowProc()
------解决方案--------------------
答案是什么
是obj.returnValue = True造成的