Declare Function OffsetRect Lib "user32.dll" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Platforms: Win 32s, Win 95/98, Win NT
OffsetRect changes the position of a rectangle without changing its size. If the value to move by is negative, the rectangle is moved left or up (depending on the direction); positive values move it right or down. The function returns 0 if an error occured, or 1 if successful.
Example:
' Shift window Form1 50 pixels right and 20 pixels up using its rectangle.
Dim winrect As RECT ' receives the rectangle of the window
Dim retval As Long ' return value
retval = GetWindowRect(Form1.hWnd, winrect) ' get Form1's rectangle
retval = OffsetRect(winrect, 50, -20) ' shift the rectangle 50 to the right and 20 upwards
' Now change the window on screen to match its new rectangle
retval = SetWindowPos(Form1.hWnd, 0, winrect.Left, winrect.Top, winrect.Right, winrect.Bottom, 0)
See Also: InflateRect
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/o/offsetrect.html