PinRect
PinRect Find point on a rectangle's border near point Rect *theRect ; rectangle into which the point is pinned returns hiword=vertical coord; loword=horiz coord
PinRect returns the coordinates inside a rectangle that most-closely match the coordinates of a specified point. If the point is inside the rectangle, it is
returned un changed. If the point is outside the rectangle, the return value is a
position on the border of the rectangle that is closest the point.
theRect is a pointer to a rectangle.
thePoint is any point (typically the position of a mouse-down event), in local
window coordinates.
Returns: a 32-bit long integer, defined as two 16-bit words that indicate the coordinates of the point, pinned to the rectangle. The return value
may be cast as a Point; it is broken up as follows: high word the vertical coordinate
low word the horizontal coordinate
Notes: After a mouse-down event, you may use PinRect to determine if the point is inside theRect or to determine the point on the rectangle that is nearest
to the mouse.
This could be used when limiting mouse drawing to a defined area - if the
mouse has moved outside of a specified area you can assume that the edge of
the area was desired.
Note that the return value is in the same order as a Point data type, so it may be cast as such for comparisons or for use in functions that need that
type of parameter.