Re: Connection Point for interfaces
"Andrey" <andrej@telemed.lt> wrote in message
news:%23%237h0a3bGHA.536@TK2MSFTNGP02.phx.gbl
Let me describe my requirements. Probably you know standard solution.
I want to implement object that supports connection points. And I want
managed languages "see" that connection point as events. But this
object is not coclass object (in my opinion). I meen that this object
can't be created
using CoCreateInstance function call. It can be only retrieved from
other objects. Does it is possible?
I know VB can support this, I don't know about C# or other .NET
languages. You still need to define a coclass in the IDL, you can mark
it with [noncreatable] attribute. Then in VB you do something like this:
Dim WithEvents myObj As MyCoclass
Set myObj = otherObj.CreateMyObj
Now you can handle events in the usual way, with Sub myObj_EventName.
I think in C# you can do something like
MyCoclass myObj;
myObj = otherObj.CreateMyObj();
myObj.EventName += new EventNameDelegator(EventHandler);
(very rough and approximate syntax, I'm really not fluent in C#).
BTW. I have found in documentation that [source] attribute can be used
not only with coclass statement, but with methods and properties. But
can't to find example of such [source] attributes usage. Do you know
such samples?
Now that you mention it, I see it in the documentation too, but I've
never seen this usage in practice and I have no idea how this is
supposed to work, nor what it might be useful for.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925