OffsetRect Function

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

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 a non-zero value if successful.

lpRect
The rectangle to move.
x
The value to move the rectangle horizontally by. Negative values move to the left, positive to the right.
y
The value to move the rectangle vertically by. Negative values move up, positive down.

Example:

' Move a rectangle 100 right and 25 up
Dim r As RECT
x = SetRect(r, 50, 50, 150, 150)  ' API function sets r = (50,50)-(150,150)
x = OffsetRect(r, 100, -25)  ' now r = (150,25)-(250,125)

Related Call: InflateRect
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/offsetrect.html