How can I use events from a late join COM object?

I have a late bound COM object ( My.COMInterface ) that raises an event when it has finished processing. How can I use this event from VB6 code?

If I were an early binding, I would declare my COM object as WithEvents and write a regular event handler. How can I achieve this using late binding?

Current Code:

 Dim comObject as Object 'Function to launch Process. Public Function LaunchProcess() As Boolean Set comObject = CreateObject("My.COMInterface") LaunchProcess= comObject.CallProcess() ' Once this process has finished, it will raise an event ' called ProcessingFinished - how do I consume it? End Function 

The only way I know this at this time is to write a C / C ++ bridge for handling events, as described in this MSDN article . I hope for an easier way!

+8
event-handling vb6 late-binding
source share
2 answers

If this is a simple COM object, I have not seen any way in the native VB6. However, if the object was a control, you can use the VBControlExtender interface and the ObjectEvent event.

+3
source share

Take a look at EventCollection Class v2.0 - add event support to the E. Morcillo collection .

Do what you want and more.

+1
source share

All Articles