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!
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.
Look at EventCollection Class v2.0 - Add event support to Collections by E. Morcillo.
Should do what you want and more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With