Important: The information in this document is obsolete and should not be used for new development.
PinRect
TheDragGrayRgn
function uses thePinRect
function to contain a point within a specified rectangle.
FUNCTION PinRect (theRect: Rect; thePt: Point): LongInt;
- theRect
- The rectangle in which the point is to be contained.
- thePt
- The point to be contained.
DESCRIPTION
ThePinRect
function returns a point within the specified rectangle that is as close as possible to the specified point. (The high-order word of the returned long integer is the vertical coordinate; the low-order word is the horizontal coordinate.)If the specified point is within the rectangle,
PinRect
returns the point itself. If not, then
- if the horizontal position is to the left of the rectangle,
PinRect
returns the left edge as the horizontal coordinate- if the horizontal position is to the right of the rectangle,
PinRect
returns the right edge minus 1 as the horizontal coordinate- if the vertical position is above the rectangle,
PinRect
returns the top edge as the vertical coordinate- if the vertical position is below the rectangle,
PinRect
returns the bottom edge minus 1 as the vertical coordinate
- Note
- The 1 is subtracted when the point is below or to the right of the rectangle so that a pixel drawn at that point lies within the rectangle. If the point is exactly on the bottom or the right edge of the rectangle, however, 1 should be subtracted but isn't.