If I have two interfaces IA and IB and an object that implements them,
usually I write the following:
[
object,
uuid(.....),
oleautomation,
nonextensible,
pointer_default(unique)
]
interface IA: IUnknown
{
HRESULT MethodA();
}
[
object,
uuid(.....),
oleautomation,
nonextensible,
pointer_default(unique)
]
interface IB: IUnknown
{
HRESULT MethodB();
}
[
object,
uuid(.....),
dual,
oleautomation,
nonextensible,
pointer_default(unique)
]
interface IDisp: IDispatch
{
[id(1)] HRESULT MethodA();
[id(2)] HRESULT MethodB();
}
coclass ObjectA
{
interface IA;
interface IB;
[default] interface IDisp;
};
But in the IDisp body I have to replicate the IA and IB bodies if I
want that it exposes them to the clients.
So, is this the right way?
For every Disp interfaces that inherits from others, I have to
replicate inherithed interfaces bodies?
Thanks,
Daniele.
http://www.sellsbrothers.com/tools/multidisp/
http://www.codeproject.com/KB/atl/multidisp.aspx
> For every Disp interfaces that inherits from others, I have to
> replicate inherithed interfaces bodies?
I'm not sure what you mean by "inherit from others". IDisp doesn't inherit from IA nor IB. You just chose, for whatever reason, to expose the same method twice on two different unrelated interfaces.
--
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
Mmmm...you're right!
And maybe this is my fault....Maybe I have to do something like this:
dispinterface IDisp
{
interface IA;
interface IB;
}
coclass Foo
{
[default] interface IDIsp;
interface IA;
interface IB;
};
Thanks.
Daniele.
No, this not work... :-(
I'm confused.
Ok, what I have to do, in c++ i write:
--- virtual interfaces ----
public class IA
public class IB : public virtual IA
public class IC : public virtual IA
--- implementations ----
public class Impl_IA {}
public class Obj1 : public Impl_IA, IB {}
public class Obj2 : public Impl_IA, IC {}
Now, How Can I translate this in IDL and ATL where the coclass are
Obj1 and Obj2?
Bye,
Daniele.
Why would you write this in C++? What is virtual inheritance supposed to achieve here? Also, how does IDispatch fit into this picture, in your mind?