- I -


InflateRect Function

Declare Function InflateRect Lib "user32.dll" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long

InflateRect increases or decreases the size of a rectangle. The values to inflate the rectangle by are added on both sides of it, so in reality the width or height increases double what you pass to it. For example, if you give it 20 as the x parameter, it will extend the left and right side by 20, so the end result is 40 wider. Positive values make the rectangle larger, and negative ones make it smaller. Mathematically, when you call the function, 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.
lpRectThe rectangle to make bigger or smaller (or both).
xThe number of pixels to expand the left and right sides by. Positive values increase the width, negative values decrease it.
yThe number of pixels to expand the top and bottom by. Positive values increase the height, negative values decrease it.
Example:
  '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


Related Call: OffsetRect
Category: RECT Manipulation
Back to the index.


IntersectRect Function

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

IntersectRect creates a rectangle based on the intersecting parts of two other rectangles. The box-shaped region where the two source rectangles overlap is the intersection rectangle. If one or both of the source rectangles are empty (see IsRectEmpty for definition of an empty rectangle) or they no not overlap anywhere, the function returns 0 and the destination rectangle is set as all 0's. If the source rectangles do overlap, the function returns 1.
lpDestRectThe rectangle to set as the intersection of the two source rectangles.
lpSrc1RectThe first source rectangle.
lpSrc2RectThe second source rectangle.
Example:
  '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


Related Calls: SubtractRect, UnionRect
Category: RECT Manipulation
Back to the index.


IsRectEmpty Function

Declare Function IsRectEmpty Lib "user32.dll" (lpRect As RECT) As Long

IsRectEmpty checks to see if a RECT-type variable contains an empty rectangle. A rectangle is considered empty if and only if its .Right is not to the right of .Left and/or its .Bottom is not below the .Top. In other words, a rectangle is empty if and only if .Right <= .Left and/or .Bottom <= .Top. The function returns 1 if the rectangle is empty, and 0 if it is not.
lpRectThe rectangle to check to see if it is empty.
Example:
  '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


Related Call: SetRectEmpty
Category: RECT Manipulation
Back to the index.


Home
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