Link to home
Start Free TrialLog in
Avatar of ad_thoma

asked on

Using CArray<CRgn, CRgn>

Hi all,
   I have created a CArray<CRgn, CRgn> member, but Unable to Add elements to the array using the CArray::Add()..

I also Found that because that the CRgn doesnot have an overoladed member function operator = , It can't be assigned in the CRgn::Add() function...

So How can I solve this issue..?

Whether Shall I use SubClassing or Should use a Pointer Array of CRgn..

Could anyone give me a suggestion with an example..


Avatar of AlexFM

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ad_thoma


Hi Alex,
   I will tell you the problem domain. I'm developing an activex control for displaying and processing ACAD drawings.
   The ACAD drawings will have n number of polylines, for each layer and normally we get the coordinates of a polylines as lines.

  So I need to display tooltips for each polylines (dynamically) as the user moves the mouse, I nned to show the tooltip.

What I'm doing now is I've a CRgn Object, and I traverse all the polylines in that drawing. I will extract the points for each polylines and construct a region using that points, now I'll check whether the current point  is inside the polyline or not using the CRgn::ptInRegion().

This will be done all the polylines and this will be keep doing as the user moves the mouse().

So its very hard to find and also consumes too much memory.

So what I thought was, If I create a CRgn Array, I can just check whether the user's mouse position is currently in which polyline..So that I don't have to get the points form the polyline and construct the region for every time..

So I thought of using a CArray of Region(CRgn).

But According to you, If I use a Pointer, then For each polyline I nned create a CRgn .. am I right..?

That too memory consuming, I have to maintian and CRgn array and also an array of CRgn* right..?

So Is there any suitable way to handle this problem..

and one more thing.. Which one should I use for this case,  CArray, CList,..CMap..

thanks In Advance,


Rajesh Parameswarn

AlexFM is correct, that is the way to do it - And I would add that you are using the correct collection class (CArray) for the job.

The difference is this -

You will have to construct all of the CRgn object before you add them to the array - but you only have to do this once for each ACAD drawing. Once you have the array of CRgn pointers, you have it.

With out the CRgn array, you are constructing these CRgn objects all the time - arent you?

Maybe I dont quite understand the problem.

Also, what is a polyline? do you mean polygon?