MoveWindow Function

Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

MoveWindow moves a window to a new location. In addition to moving it, this function also changes the window's size to a new width and height. The function returns 1 if successful, or 0 if an error occured.

hwnd
The handle of the window to move and resize.
x
The x-coordinate to position the upper-left corner of the window at.
y
The y-coordinate to position the upper-left corner of the window at.
nWidth
The width in pixels to resize the window to.
nHeight
The height in pixels to resize the window to.
bRepaint
If 1, updates the screen to display the window at its new position. If 0, does not update the screen to reflect the move (the window will appear to be unmoved but will actually be at its new location!).

Example:

' Move window Form1.  Set its upper-left corner to the point (200, 150).
' Change its size to a width of 175 and a height of 300.
Dim retval As Long  ' return value

' Move the window and make sure it's redrawn at its new position.
retval = MoveWindow(Form1.hWnd, 200, 150, 175, 300, 1)
' (If the last value had been 0, the window would have appeared to be unmoved!)

See Also: GetWindowRect, SetWindowPos
Category: Windows

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/m/movewindow.html