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");
:)

Edited 6 Years Ago by CppBuilder2006: n/a

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.

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!

Edited 6 Years Ago by CppBuilder2006: n/a

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

Edited 6 Years Ago by jonsca: n/a

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.

Edited 6 Years Ago by jonsca: n/a

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 ..

This question has already been answered. Start a new discussion instead.