
ATL inheritance from 2 different DLLs
This cannot be done directly - aggregation is not an option. You
must use containment in addition to the interface derivation.
Let's say you have coclass CC1 implementing interface I1 in DLL1,
and coclass CC2 implementing I2 deriving from I1 in DLL2. You
have to implement the methods of both I1 and I2 in CC2. To
implement I1, you create an instance of CC1 and forward each
I1 method to this contained instance. See FinalConstruct and
FinalRelease - these are the places to create and release
respectively the contained COM object instance.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Quote:
> Yes, but my problem is I don't know where to start...
> Can I do aggregation using 2 components from separate DLLs?
> > do u mean using I2 to aggregate I1?
> > > I have been going thru alot of post today and I can't seem to put my
> > > finger on the solution I need.
> > > Using ATL I want to create 2 dlls with 1 interface each:
> > > DLL1 -> I1
> > > DLL2 -> I2
> > > Interface I1 has the following methods:
> > > I1 -> M1()
> > > I1 -> M2()
> > > Interface I2 has the following methods:
> > > I2 -> M3()
> > > I2 -> M4()
> > > The tricky part though is that I need I2 to inherit the I1 methods (in
> > > C++ terms I would say that I2 would derive from I1) without
> > > duplicating any code so that I can change any DLL anytime I want. This
> > > way an application that uses my component could call DLL2->I2->M1()
> > > and be transparently redirected to DLL1->I1->M1(). Is this possible
> > > using ATL?
> > > I understand the use of templates to do the job but most of the
> > > solutions I found seems to be for interfaces defined in the same DLL
> > > only. Is this right?
> > > Any help and pointers would be greatly appreciated.
> > > Thanks
> > > Patrick Moreau