EqualRgn Function

Declare Function EqualRgn Lib "gdi32.dll" (ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long) As Long

Platforms

Description & Usage

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.

Return Value

If the two regions are equal, the function returns a non-zero value. If the two regions are different, the function returns zero.

Visual Basic-Specific Issues

None.

Parameters

hSrcRgn1
A handle to the first of the two regions to compare.
hSrcRgn2
A handle to the second of the two regions to compare.

Example

Perform a simple illustration of equal and unequal regions. Besides showing how the function works, there's no practical value to this example. The example runs when you click on command button Command1 in a form window. So, naturally, there has to be a command button named Command1 on that window.

' This code is licensed according to the terms and conditions listed here.

' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Declare Function EqualRgn Lib "gdi32.dll" (ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 _
	As Long) As Long
Public Declare Function CreateEllipticRgn Lib "gdi32.dll" (ByVal nLeftRect As Long, _
	 ByVal nTopRect As Long, ByVal nRightRect As Long, ByVal nBottomRect As Long) As Long
Public Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long

' *** Place the following code inside a form. ***

Private Sub Command1_Click()
	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)
	
	' Compare regions 1 and 2 (they will be equal).
	areequal = EqualRgn(hRgn1, hRgn2)
	If areequal = 0 Then Debug.Print "Not Equal" Else Debug.Print "Equal"
	
	' Compare regions 1 and 3 (they will not be equal).
	areequal = EqualRgn(hRgn1, hRgn3)
	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)
End Sub

Category

Regions

Go back to the Function listing.
Go back to the Reference section index.


Last Modified: July 30, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/e/equalrgn.html