|
||||
UnionRectCategory: RectangleHits: 3306 Rating: (2.42) votes 1044
Rate: 1-star 2-stars 3-stars 4-stars 5-stars
API Explanation
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. Parameter Information Declare Function UnionRect Lib "user32.dll" (lpDestRect As _ RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long lpDestRect Variable that receives the union rectangle. lpSrc1Rect The first of the two source rectangles. lpSrc2Rect The second of the two source rectangles.
Code
' 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) |