Declare Function IsRectEmpty Lib "user32.dll" (lpRect As RECT) As Long
Platforms: Win 32s, Win 95/98, Win NT
IsRectEmpty checks to see if a rectangle is empty. A rectangle is considered empty if its right edge is not to the right of its left edge and/or its bottom edge is not below its top edge. For example, a rectangle (50,50)-(25,100) is empty because the right edge is to the left of the left edge. The function returns 1 if the rectangle is empty and 0 if it is not.
Example:
' Determine if windows Form1 and Form2 are overlapping on the
' screen. If they don't the intersection rectangle will be empty.
Dim intrect As RECT ' receives the intersection rectangle
Dim window1 As RECT, window2 As RECT ' receive rectangles of Form1 and Form2
Dim isempty As Long ' will be set to 0 if intersection isn't empty, 1 if it is
Dim retval As Long ' return value for other functions
retval = GetWindowRect(Form1.hWnd, window1) ' get Form1's rectangle
retval = GetWindowRect(Form2.hWnd, window2) ' get Form2's rectangle
retval = IntersectRect(intrect, window1, window2) ' determine the intersection rectangle
isempty = IsRectEmpty(intrect) ' determine if it is empty -- it will be if there's no intersection
If isempty = 0 ' in this case, intrect will also be empty
Debug.Print "Windows Form1 and Form2 are not overlapping on the screen."
Else
Debug.Print "Windows Form1 and Form2 are overlapping on the screen."
End If
See Also: SetRectEmpty
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/i/isrectempty.html