How to handle ihtmldocument2.onmouseover event in. net

Source: Internet
Author: User

Some ActiveX controls use the default method of the idispatch interface to implement the event mechanism. How to use such Event Callback in. Net?
1 )? Define a class, define the event processing method, and add It is the default method of the idispatch interface of this class. The following is an example:
Public class InterOP
Public sub onmouseover ()
MessageBox. Show ("Mouseover ")
End sub
End Class

2) But if you write
Ihtmldocument2 Doc = axwebbrowser1.document
Doc. onmouseover = new InterOP
Then, a not_implemented exception will be generated during the runtime, because by default, InterOP uploaller of. NET will convert marshal into variant of the vt_unknown type, and we need to convert the marshal into Variant of vt_dispatch. We can use disptachwrapper provided by. Net to solve this problem.
Doc. onmouseover = new dispatchwrapper (New InterOP)
When you no longer need to handle this event, you can use the following method to disconnect the event handler.
Doc. onmouseover = new dispatchwrapper (nothing)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.