|
-
October 8th, 1999, 09:20 AM
#1
COM events
I have a C++ method that returns an IDispatch pointer as a return parameter. If that object is an event source, is there a way for a VB client that calls that method to recognize that object as a source of events and to dynamically tie that object to event procedures so that it can respond to events from the object?
-
October 8th, 1999, 02:30 PM
#2
Re: COM events
I am answering my own post in case anyone else cares. In short, yes VB can do this. Instantiate class module, with an unitialized member of the eventsource object type withEvents. Define the relevant event procedures for it. Define a method to set the member variable. Once it is set dynamically at runtime, events are received from the object. To stop events, set the member variable to nothing. A code sample follows.
Private WithEvents m_EventSource As RETURNEVENTSRCTESTSERVERLib.MyEventSrc
Private Sub m_EventSource_MyEvent(ByVal lEvent As Long)
MsgBox ("Got an event")
End Sub
Public Sub SetEventSrc(evtsrc As Object)
Set m_EventSource = evtsrc
End Sub
-
October 9th, 1999, 01:23 AM
#3
Re: COM events
One more point:
You cannot do this defining a event source with dim/private WITHEVENTS identifier w/o first referencing the dll or tlb for that source. i.e
If you want this line:
private withevents m_EventSource as RETURNEVENTSRCTESTSERVERLib.MyEventSrc
to go thru the compilation before running (Cntrl+F5) the library reference to RETURNEVENTSRCTESTSERVERLib should first be set. and thats when the custom events will be understood by VB.
RK
-
November 24th, 2000, 05:13 AM
#4
Re: COM events
How would be done the other way around. How can
events be handled in VC ? If the com is developed in VB..
Thanx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|