SubtractRect Function

Declare Function SubtractRect Lib "user32.dll" (lprcDst As RECT, lprcSrc1 As RECT, lprcSrc2 As RECT) As Long

SubtractRect subtracts a smaller rectangle from a larger one. Rectangle subtraction is defined as follows. The large and small rectangles must intersect completely along one entire side, neither extanding farther along that side than the other. That is, they share a common side. All of the large rectangle that is not also part of the small rectangle is also a rectangle. This rectangle is the subtraction rectangle. This rectangle is put into the variable passed as lprcDst. If the two rectangles fail to meet the criteria, lprcDst is set equal to the large rectangle and the function returns 0. If subtraction is possible, the function returns 1.

lprcDst
Variable that receives the subtraction rectangle.
lprcSrc1
The large rectangle; that is, the rectangle subtracted from.
lprcSrc2
The small rectange; that is, the rectangle subtracted.

Example:

' Rectangle subtraction
Dim target as RECT, big As RECT, small As RECT
x = SetRect(big, 50, 50, 150, 100)  ' big = (50,50)-(150,100)
x = SetRect(small, 50, 50, 100, 100)  ' small = (50,50)-(100,100)
x = SubtractRect(target, big, small)  ' target = (100,50)-(150,100)

Related Calls: IntersectRect, UnionRect
Category: Rectangles
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/subtractrect.html