Deriving a COM interface from another COM interface using ATL/COM

Deriving a COM interface from another COM interface using ATL/COM

Post by Mousa » Tue, 26 Feb 2008 21:20:26


Hi All,
Is there any way to derive an interface from another interface
using ATL/COM?

I am having two interfaces IA and IB. I want to derive IB from IA and
then I want to create a COM object which derives from IB. Can any one
please tell me how can we achieve this using ATL/COM?

Thanks & Regards,
Mousam Dubey
 
 
 

Deriving a COM interface from another COM interface using ATL/COM

Post by Igor Tande » Tue, 26 Feb 2008 22:04:11


Yes. After all, every single interface is happily derived from IUnknown.


In your IDL, just write

[...]
interface IA : IUnknown { ... };

[...]
interface IB : IA { ... };

Then in your component implement IB just as you would any other
interface. Don't forget to list both IB and IA in the interface map.
--
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

 
 
 

Deriving a COM interface from another COM interface using ATL/COM

Post by Mousa » Wed, 27 Feb 2008 02:39:21


Hi,
Thanks Igor for your prompt response. I did the things as suggested
by you, but now when I add a method/property to
IA through ATL wizard, that method/property does not automatically
declared in CB (component which implements IB). Also I dont see any
default definition for that method/property in CB. I have to manually
provide declaration and definition for all methods/properties which I
am adding to IA.

Am I doing something wrong here or is there some kind of problem with
VS 2005?

Thanks & Regards,
Mousam Dubey
 
 
 

Deriving a COM interface from another COM interface using ATL/COM

Post by Igor Tande » Wed, 27 Feb 2008 02:46:23


Luckily, you have a perfectly good text editor at your disposal.
--
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
 
 
 

Deriving a COM interface from another COM interface using ATL/COM

Post by Mousa » Wed, 27 Feb 2008 18:03:19


:)

Thanks & Regards,
Mousam Dubey