Declare Function EqualRect Lib "gdi32.dll" (ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long) As Long
Platforms: Win 32s, Win 95/98, Win NT
EqualRgn determines if two regions contain the exact same area. Although the region handles will of course be different, they could still refer to regions of identical size, shape, and position. The function returns a non-zero value if the two regions refer to identical areas, or 0 if they refer to different areas.
Example:
' Illustrate equal and unequal regions. Three different regions are
' compared, two of them equal and the third not equal to the others.
Dim hRgn1 As Long, hRgn2 As Long, hRgn3 As Long ' the three regions
Dim areequal As Long ' receives equal/unequal indicator
Dim retval As Long ' generic return value
' Define all three regions as elliptical.
hRgn1 = CreateEllipticRgn(20, 30, 120, 80)
hRgn2 = CreateEllipticRgn(20, 30, 120, 80)
hRgn3 = CreateEllipticRgn(50, 50, 200, 150) ' this is different
' Compare regions 1 and 2 (they should be equal).
areequal = EqualRgn(hRgn1, hRgn2) ' areequal will be nonzero
If areequal = 0 Then Debug.Print "Not Equal" Else Debug.Print "Equal"
' Compare regions 1 and 3 (they should not be equal).
areequal = EqualRgn(hRgn1, hRgn3) ' areequal will be zero
If areequal = 0 Then Debug.Print "Not Equal" Else Debug.Print "Equal"
' Delete the three regions to free up resources.
retval = DeleteObject(hRgn1)
retval = DeleteObject(hRgn2)
retval = DeleteObject(hRgn3)
Category: Regions
Back to the index.