- P -


PtInRect Function

Declare Function PtInRect Lib "user32.dll" (lpRect As RECT, x As Long, y As Long) As Long

PtInRect determines if a point lies inside or outside of a rectangle. Note that points along the top and left sides are considered inside, while those along the right and bottom sides are considered outside. The function returns 1 if the point is inside, and 0 if it is outside.
lpRectThe rectangle to search inside.
xThe x-coordinate of the point to determine if it is inside or outside.
yThe y-coordinate of the point to determine if it is inside or outside.
Example:
  'Example of outside/inside the rectangle
  Dim r As RECT
  x = SetRect(r, 50, 50, 150, 150) '.Left = 50, .Top = 50, .Right = 150, .Bottom = 150
  Form1.Print PtInRect(r, 75, 100) 'returns 1 -- it is inside
  Form1.Print PtInRect(r, 100, 100) 'returns 0 -- it is outside


Category: RECT Manipulation
Back to the index.


Home
Paul Kuliniewicz
E-mail: Borg953@aol.com
All material presented on these pages is Copyright © Paul Kuliniewicz, except for other copyrighted material.
http://members.aol.com/Borg953/api/p.html