WPF WebBrowser Mouse Events not working as expected

前端 未结 2 1076
無奈伤痛
無奈伤痛 2020-11-29 12:34

I have a WebBrowser object in a WPF Page and I\'m trying to do something whenever the user interacts with the page. I have intially tried to use the events associated with t

相关标签:
2条回答
  • 2020-11-29 13:08

    Mouse events are not supported by the WebBrowser control, according to the documentation. You need to hook up handlers to the DOM events provided by the document being displayed in the control, using the WebBrowser.Document property. This post has an example of how to do this.

    0 讨论(0)
  • 2020-11-29 13:32

    Add the ms html com library

    Once the WebBrowser.LoadCompleted event fires try this:

    mshtml.HTMLDocumentEvents2_Event doc = ((mshtml.HTMLDocumentEvents2_Event)Browser.Document);
    doc.onmouseover += new mshtml.HTMLDocumentEvents2_onmouseoverEventHandler(doc_onmouseover);
    

    or use some other event.

    Hope this helps someone.

    0 讨论(0)
提交回复
热议问题