Declare Function InflateRect Lib "user32.dll" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
x
is added to .Right and subtracted from .Left, and y
is added to .Bottom and subtracted from .Top. You can safely ignore the value returned.lpRect | The rectangle to make bigger or smaller (or both). |
x | The number of pixels to expand the left and right sides by. Positive values increase the width, negative values decrease it. |
y | The number of pixels to expand the top and bottom by. Positive values increase the height, negative values decrease it. |
'Expand a rectangle by 30 on left and right and -10 on top and bottom
Dim r As RECT
x = SetRect(r, 50, 50, 100, 100) 'API function that sets rectangle size
'.Left = 50, .Top = 50, .Right = 100, .Bottom = 100
x = InflateRect(r, 30, -10)
'Now, .Left = 20, .Top = 60, .Right = 130, .Bottom = 90
Declare Function IntersectRect Lib "user32.dll" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
lpDestRect | The rectangle to set as the intersection of the two source rectangles. |
lpSrc1Rect | The first source rectangle. |
lpSrc2Rect | The second source rectangle. |
'Demonstration of IntersectRect
Dim target As RECT, s1 As RECT, s2 As RECT
x = SetRect(s1, 50, 50, 150, 150) 'API function sets rectangle at (50,50)-(150,150)
x = SetRect(s2, 100, 100, 200, 200) '(100,100)-(200,200)
x = IntersectRect(target, s1, s2)
'target.Left = 100, .Top = 100, .Right = 150, .Bottom = 150
Declare Function IsRectEmpty Lib "user32.dll" (lpRect As RECT) As Long
lpRect | The rectangle to check to see if it is empty. |
'Demonstration of what is considered empty
Dim r As RECT
x = SetRect(50, 50, 40, 100) '.Right < .Left
Form1.Print IsRectEmpty(r) 'Returns 1
x = SetRect(50, 50, 100, 100) '.Left < .Right and .Top < .Bottom
Form1.Print IsRectEmpty(r) 'Returns 0
x = SetRect(50, 50, 100, 50) '.Top = .Bottom
Form1.Print IsRectEmpty(r) 'Returns 1
Paul Kuliniewicz
E-mail: Borg953@aol.com
All material presented on these pages is Copyright © Paul Kuliniewicz, except for other copyrighted material.
http://members.aol.com/Borg953/api/i.html