Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I consume events from a late-bound COM object?

I have a late-bound COM object (My.COMInterface) which raises an event when it has finished processing. How do I consume that event from VB6 code?

If I was early-binding, I would declare my COM object as WithEvents, and write a normal 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 to do it currently is to write a C/C++ bridge to handle the events, as described in this MSDN article. I'm hoping for a simpler method!

like image 325
RB. Avatar asked Nov 07 '11 10:11

RB.


2 Answers

If it's a plain COM object, I've not seen any way in native VB6. If the object was a control however, you could use the VBControlExtender interface and the ObjectEvent event.

like image 184
Deanna Avatar answered Oct 18 '22 11:10

Deanna


Look at EventCollection Class v2.0 - Add event support to Collections by E. Morcillo.

Should do what you want and more.

like image 28
wqw Avatar answered Oct 18 '22 11:10

wqw