Re: Connection points and aggregation
Barnab? <eric.franc@gmail.com> wrote:
MainObject.h
BEGIN_COM_MAP(MainObject )
COM_INTERFACE_ENTRY(IMainObject )
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY_AGGREGATE( __uuidof(AggObject),
mpoAggregation.p)
Don't you mean to use __uuidof(IAggObject) here?
COM_INTERFACE_ENTRY_AGGREGATE expects an IID of an interface, not a
CLSID of a coclass.
COM_INTERFACE_ENTRY_AGGREGATE( __uuidof(IConnectionPointContainer),
mpoAggregation.p)
END_COM_MAP()
idl file
[
uuid(917DCC4C-2E52-4E9F-9FEF-420277FA139D),
helpstring("ATRTranslator Class")
]
coclass ATRTranslator
{
[default] interface IMainObject ;
[source] interface IAggObject;
The [source] attribute here is suspicious. Is IAggObject the interface
you (or your inner) implement, or the outgoing interface you fire events
on and expect clients to implement? If it's the former, it should not
have [source] attribute. If it's the latter, it shouldn't appear in your
interface map,
[source] interface IConnectionPointContainer;
This line does not make sense, remove it entirely.
};
Now when I launch my application, the AtlAdvise return S_OK, but I
still can't catch my event.
Are you sure any events are fired in the first place? Since AtlAdvise
succeeds, IConnectionPointContainer is correctly exposed. The failure
must be elsewhere - either the event is never fired, or your sink is set
up incorrectly.
--
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