Easiest way to make ATL Simple Objects: aggragatable + aggragating & test them.

I'm looking for a tutorial or if anybody can tell me:
How do I make a project with two combined objects: one aggregating and one aggregatable.
I'm looking to use as few as possible code inside, mostly the menu's wizards and helper functions.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Choose Yes or Only for Aggregation in the ATL Object Wizard. And

Creating an Aggregate

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mflamAuthor Commented:
Hello chensu,

I'm not sure I understood correctly:
1. Is this what I should do?:
In ATL I make a simple object and checked the ONLY for aggravation.
The object is an elephant's trunk, called "TrunkObj", with a method called "spritz()".

Now to aggregate the TrunkObj into my elephant obj, I create a simple ATL object called "ElephantObj".
Then follow the instructions in the MSDN tut you pointed me to?

2. Will doing this cause the following?
A. I will not be able to call myTrunk.spritz. (Say in Visual Basic)?
B. I will be able to make an Elephant.Spritz() method, that will call the m_Trunk.Spritz()? or...

C. I don't understand aggregation, and the concept is something else? (which is?)

3. Last question: Is this the easiest way in VC++6, or is there some clickable menu/wizard/popup somewhere that will do this automatically for me?


1. If you choose ONLY, the object can be used ONLY thru aggregation.

2. That is containment instead of aggregation. See


3. Why does Microsoft documentation tell you a harder way if there is an easier way?
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

I think it will be difficult for
you to implement the object
(at least professionally) without
some basic understanding of aggregation.

Your question is not very clear to me.
Can u elaborate more.
mflamAuthor Commented:
Chensu, thanks.
Could you post a peace of code with an actual aggragate. (Not everything is there in the example, and the sample has too much.)

About my "easiest way" question: MSDN has tons of info, from older versions, and some very detailed examples. They  don't always show the easiest way.
Even in THIS example:
1. They did not show how to release the aggragate, just said where to do it.
2. They used CoCreateInstance and not an ATL smartpointer.
3. I'm still not sure there is no "Add New ATL Class" trick that will add everything automatically.

Thanks again, Moshe
mflamAuthor Commented:
Basant hello,

I wanted to be sure I understood correctly. I have the answer to that, it's yes.
My questions are now practical:
1. I would like to see a few peaces of code completely covering the aggravation.
2. I would like to know if (despite the MSDN) there is some button that would do most of it or all of it automatically. (Like the "implement connection point").

I will consider any of these 2 as an answer. preferebly both (and added 50 points)

I have code written in Win32 which
shows aggregation. If u want I can
mail it to you. You can give ur mail
id to me.

In ATL what I know is you only
specify a MACRO to allow the
object to support AGGREGATION
but in Win32 you actually do it urself.
It also took me some time to understand
those concepts.

The following KB article shows you how to aggregate a COM object in an ATL project.

HOWTO: Aggregate a COM Object with ATL
mflamAuthor Commented:
Thank you!
I now have 900 expert points and only 50 regular. How do I get more points for regular questions?
mflamAuthor Commented:
Basant hello,

I completely understand the Win32 C COM aggragation. In fact, I even have objects written using it.
I wanted:
1. To be sure I understood correctly. (which apparently I did).
2. I wanted ATL code.

Thank you for your comments.

>How do I get more points for regular questions?

It increases by 5 points every day as long as you keep active.
mflamAuthor Commented:
Wait! I now have a last question for this line.
I want to use smartpointers instead of the CoCreateInstance of the example.
I #import the AggObj.DLL and include it's AggObj_i.c file.
1. Do I call CoInitialize(NULL); ?
2. Do I call the m_pAgg->Release();
in the FinalRelease() ?

mflamAuthor Commented:
I also did not undersand you answer about points.
I need another 100 points for an important question.
How do I get them?
(I cannot wait so many days...)

>1. Do I call CoInitialize(NULL); ?

Yes, you need to call it and CoUnintialize() in the end.

>2. Do I call the m_pAgg->Release();
in the FinalRelease() ?

If m_pAgg is a smart pointer, you don't have to call it.

>I need another 100 points for an important question. How do I get them?

Wait or click the More Points! link at the bottom of the page.

Dear mflam

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept


comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

Per recommendation, force-accepted by
CS Moderator
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.