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)