UnionRect Function

Declare Function UnionRect Lib "user32.dll" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long

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

UnionRect determines the smallest possible rectangle that contains two other rectangles. This rectangle is called the union rectangle because it is derived from the union of the areas that the two source rectangles occupy. The union rectangle is put into the variable passed as lpDestRect. The function returns 0 if an error occured, or 1 if successful.

lpDestRect
Variable that receives the union rectangle.
lpSrc1Rect
The first of the two source rectangles.
lpSrc2Rect
The second of the two source rectangles.

Example:

' Create a large rectangle that contains the areas occupied by
' rectangles s and t.  The new rectangle will fully contain both smaller rectangles.
' s = (20,30)-(60,80); t = (100,110)-(200,300)
Dim s As RECT, t As RECT  ' small rectangles
Dim urect As RECT  ' receives the union rectangle
Dim retval As Long  ' return value

' Set the small rectangles
retval = SetRect(s, 20, 30, 60, 80)  ' set s = (20,30)-(60,80)
retval = SetRect(t, 100, 110, 200, 300)  ' set t = (100,110)-(200,300)

' Figure out the union rectangle
retval = UnionRect(urect, s, t)  ' now urect = (20,30)-(200,300)

See Also: IntersectRect, SubtractRect
Category: Rectangles

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


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/u/unionrect.html