[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

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.
0
mflam
Asked:
mflam
  • 7
  • 5
  • 2
  • +2
1 Solution
 
chensuCommented:
Choose Yes or Only for Aggregation in the ATL Object Wizard. And

Creating an Aggregate
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/devprods/vs6/visualc/vcmfc/_atl_creating_an_aggregate.htm
0
 
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?

Thanks!

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

2. That is containment instead of aggregation. See

http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/devprods/vs6/visualc/vcmfc/_atl_aggregation.htm

3. Why does Microsoft documentation tell you a harder way if there is an easier way?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
basantCommented:
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.
0
 
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
0
 
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)

Moshe
0
 
basantCommented:
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.

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

HOWTO: Aggregate a COM Object with ATL
http://support.microsoft.com/support/kb/articles/Q173/8/23.ASP
0
 
mflamAuthor Commented:
Thank you!
I now have 900 expert points and only 50 regular. How do I get more points for regular questions?
0
 
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.

Moshe
0
 
chensuCommented:
>How do I get more points for regular questions?

It increases by 5 points every day as long as you keep active.
0
 
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.
BUT:
1. Do I call CoInitialize(NULL); ?
2. Do I call the m_pAgg->Release();
in the FinalRelease() ?

Thanks...
0
 
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...)

Moshe
0
 
chensuCommented:
>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.

http://www.experts-exchange.com/secure/bin/MorePoints
0
 
griesshCommented:
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

     "chensu"

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/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
NetminderCommented:
Per recommendation, force-accepted by
Netminder
CS Moderator
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 7
  • 5
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now