## CppBuilder2006 -5

I have region:

``Region r``

and I have a point:

``PointF p``

is there any method that determines whether p is in r?
something like this

``````bool is_p_in_r = graphics.Determine(p,r);
if(is_p_in_r)
Execute("theMan.kil");
:)``````

## jonsca 1,059

Can you use `RectangleF rf = r.GetBounds(graphics);` then `if(rf.Contains(p))` do whatever? I'm assuming that graphics is of type Graphics and is initialized somehow.

## CppBuilder2006 -5

Can you use RectangleF rf = r.GetBounds(graphics); then if(rf.Contains(p)) do whatever?

well .. if the region is circular then there may be points in rf that are not in the region! in other words rf is a superset of the region!

## jonsca 1,059

I gotcha. I had that possibility in the back of my mind but I wasn't sure how the regions were defined. Apologies.

## jonsca 1,059

There's also the intersect method of the region itself. It requires a rectangle but send your point in as a 1 pixel by 1 pixel rectangle. If the intersection is empty you'll know the point is not there (looks like you need to save a copy of your region first since it will clobber it with the result when you call the method). I don't think that makes any assumptions about the shape of the region.

## CppBuilder2006 -5

There's also the intersect method of the region itself. It requires a rectangle but send your point in as a 1 pixel by 1 pixel rectangle. If the intersection is empty you'll know the point is not there (looks like you need to save a copy of your region first since it will clobber it with the result when you call the method). I don't think that makes any assumptions about the shape of the region.

thanks. I think it works... it's like a mathematical trick ..
I was going to code it but.. accidentally I found the polymorphic method `isVisible` ..