PtInRect
PtInRect Find if a point is enclosed by a rectangle Point thePoint; point of interest Rect *theRect ; rectangle to query returns Is thePoint inside of theRect ?
PtInRect returns TRUE if a specified point (actually the pixel below and to the right of the point) is enclosed by a specified rectangle.
thePoint is any point on the coordinate plane, in either local or global
coordinates.
theRect is the address of a rectangle structure, using the same coordinate
system as thePoint .
Returns: a Boolean value indicating whether or not thePoint is enclosed by theRect . It is one of:
Notes: If thePoint is on the bottom or rightmost border of theRect, this function
returns FALSE, since the mathematical border of the rectangle is infinitely thin and thus, is not part of the pixels enclosed by the rectangle.
If you use this function often in time-critical code, you may wish to avoid
the trap overhead and use a series of integer comparisons instead; e.g.:
if ( (p.h > r.top) && (p.h < r.bottom)
&& (p.v > r.left) && (p.v < r.right) ) . . .
Use PinRect to move a point from outside to inside a rectangle.