EqualRect Function

Declare Function EqualRect Lib "user32.dll" (lpRect1 As RECT, lpRect2 As RECT) As Long

Platforms: Win 32s, Win 95/98, Win NT

EqualRect determines if two rectangles are equal. Rectangles are considered equal if and only if the upper-left and lower-right corners (the points that define the rectangles) of one rectangle are equal to those of another. The function returns 1 if the two rectangles are equal and 0 if they are unequal.

lpRect1
The first of the two rectangles to check.
lpRect2
The second of the two rectangles to check.

Example:

' Demonstrate equal and unequal rectangles
Dim r As RECT, s As RECT  ' rectangles to use
Dim areequal As Long  ' receives whether the rectangles are equal or not
Dim retval As Long  ' return value

' Initialize the two rectangles using the API
retval = SetRect(r, 15, 20, 100, 110)  ' r = (15,20)-(100,110)
retval = SetRect(s, 15, 20, 100, 110)  ' s = (15,20)-(100,110)
areequal = EqualRect(r, s)  ' compare the rectangles
If areequal = 1 Then Debug.Print "Are Equal" Else Debug.Print "Are Not Equal"
' Change the second rectangle
retval = SetRect(s, 30, 45, 200, 250)  ' s = (30,45)-(200,250)
areequal = EqualRect(r, s)  ' compare the rectangles
If areequal = 1 Then Debug.Print "Are Equal" Else Debug.Print "Are Not Equal"
' The first time is Are Equal, the second is Are Not Equal.

Related Call: CopyRect
Category: Rectangles
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/e/equalrect.html