I'm also working from theory, but when you want to *use* an alternate
interface, you've got to Dim a second variable as the alternate interface
type, and then set the two vars equal to one another.
Maybe that same approach will work for the events? So for instance:
Dim WithEvents objFirst as clsFirstInterface
Dim WithEvents objSecond as clsSecondInterface
Set objFirst = New clsFirstInterface
Set objSecond = New clsSecondInterface
Set objSecond = objFirst
HTH,
-Roy
-----Original Message-----
From: Amit Jain [mailto:Amit.Jain@e...]
Sent: Thursday, April 19, 2001 7:56 AM
To: professional vb
Subject: [pro_vb] RE: How to implement event sinks in VB on a componen
t?
No, the events are different on different interfaces, but on the same
component (or same class). A sample IDL of the situation I am in is below:
[
object,
oleautomation,
uuid(CEXY4565-2758-11d3-80WS-00532462E955),
pointer_default(unique)
]
interface IA : IUnknown
{
[helpstring("Event AA")]
HRESULT TaskAA([in] BSTR taskname);
[helpstring("Event AB")]
HRESULT TaskAB([out, retval] VARIANT_BOOL *give_up);
};
[
object,
oleautomation,
uuid(FDF1E006-5E28-11D3-80EA-00432462E999),
pointer_default(unique)
]
interface IB : IUnknown
{
[helpstring("Event BA")]
HRESULT TaskBA([in] BSTR function );
[helpstring("Event BB")]
HRESULT TaskBB([in] long num);
};
[
uuid(79D6DC46-28A8-11D3-80D0-76243462E955),
helpstring("Events Class")
]
coclass Events
{
[default] interface IConnectionPointContainer;
[default, source] interface IA;
[source] interface IB;
};
Hope this clears the question.
-----Original Message-----
From: Yehuda Rosenblum [mailto:Yehuda@I...]
Sent: Thursday, April 19, 2001 9:01 AM
To: professional vb
Subject: [pro_vb] RE: How to implement event sinks in VB on a component?
If I understand you correctly you are saying you have two interfaces
that you want to catch one event. As far as I nknow once an event is
caught another interface cannot catch it (I may be wrong; I am basing
this off theory. I haven't done extensive work with custom events).
-----Original Message-----
From: amit jain [mailto:amit.jain@e...]
Sent: Wednesday, April 18, 2001 5:00 PM
To: professional vb
Subject: [pro_vb] How to implement event sinks in VB on a component?
I have a component that has two connection points (2 interfaces). One of
them is the default source interface. And the other is just a source
interface. When I use the statement 'Dim WithEvents firstinterface as
Component', I can trap the events that are generated on the first
interface which is the default source interface. I couldnt figure out a
way of trapping the events on the second source interface. Can anyone
suggest how to get this done in VB. The default incoming interface on
the
component is the IConnectionPointContainer interface.
Thanks.