0

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 by CppBuilder2006: n/a

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by CppBuilder2006
Featured Replies
  • 1
    jonsca 1,059   7 Years Ago

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

  • 1
    jonsca 1,059   7 Years Ago

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

  • 1
    jonsca 1,059   7 Years Ago

    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 … Read More

1

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.

0

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 by CppBuilder2006: n/a

1

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

Edited by jonsca: n/a

1

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 by jonsca: n/a

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.