Re: Accessing ClassA's properties from within ClassB
"Phil Goddard" <PhilGoddard@discussions.microsoft.com> wrote in message
news:FBECDFDE-96C3-429C-8583-EF831C6BFE00@microsoft.com
The design I have in mind is for the ATL class methods to accept
other ATL class objects as their input, I then extract the pointer to
the C++ object in the input class and use it's (C++) methods to do
what I need to do.
If you insist, you can do the following. Define a new IID in your code
(say, IID_ClassA), don't publish it anywhere. In ClassA's interface map,
add
COM_INTERFACE_ENTRY_IID(IID_ClassA, ClassA);
Now your classes can query IClassA interface pointer for IID_ClassA, and
get back raw ClassA pointer (assuming IClassA is indeed implemented by
ClassA - otherwise QI will fail). Rememeber that, even though QI for
IID_ClassA returns raw class rather than an interface pointer, it still
AddRef's internally, and you need to Release to balance out the
reference count.
--
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