PtInRect Function

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

PtInRect determines if a point lies inside or outside of a rectangle. Note that Windows considers the left and top edges of a rectangle to be inside it, and the right and bottom edges to be outside. The function returns 1 if the point is inside or 0 if it is outside.

lpRect
The rectangle to look inside.
x
The x coordinate of the point to determine if it is inside or outside.
y
The y coordinate of the point to determine if it is inside or outside.

Example:

'Example of inside/outside a rectangle
Dim r As RECT
x = SetRect(r, 50, 50, 150, 150)  ' API function sets r = (50,50)-(150,150)
Debug.Print PtInRect(r, 75, 100)  ' returns 1 -- inside
Debug.Print PtInRect(r, 100, 100)  ' returns 0 -- outside

Category: Rectangles
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/ptinrect.html