
Objects in Collection and Raise Events
I have read the archives on dejanews and I'm still not sure, so I
thought I'd ask this (in vb.general.discussion and in vb.com):
I have a COM object (in an ActiveX DLL). It raises events with
RaiseEvent.
I have a standard exe with a collection of that object. The object was
dimmed WithEvents. The collection cannot be dimmed with events. I am
passing an arg on the event which is a key to the collection.
In debug, the RaiseEvent in the class module executes OK, no errors.
But the event handler in the form module never gets entered.
MSDN didn't mention this being a problem that I could find. I read the
news archives and it looked like I was trying something that can't be
done. So....
I changed the com object to do callbacks instead of raise events:
I moved all of the code which handles the collection from the standard
exe form into a private class in the same project. In that class the
former event handlers are now public methods, thus part (the only part)
of the default interface. In the original object (for the collection),
there are two changes:
1) It has a new property of type "object" - to be set for the callbacks.
2) It doesn't RaiseEvent anymore - it says "Call newproperty.Method
(args, etc)"
And also back in the private class of the standard exe, I set the
newproperty to "Me" in every brand new object.
This all seems to work, though I am going to do some more thorough
testing.
But did I need to do it? Was there an easier way? Can you RaiseEvents
from objects in collections and I was just missing something about why
I wasn't receiving the events in the original version?
And finally, how about RaiseEvents from objects in arrays?
Thanks in advance, C
Sent via Deja.com http://www.*-*-*.com/
Before you buy.