Name

SetWindowPos

Synopsis

Allows a window’s size, position, or location in the window Z-order to be modified:

Public Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
		(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
		ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
		ByVal cy As Long, ByVal wFlags As Long) As Long

Parameters

hwnd

The handle of the window being modified.

hWndInsertAfter

The handle of the window that comes before this window in the Z-order. This argument also can take the following constants:

HWND_BOTTOM (1)

Places the window at the bottom of the Z-order.

HWND_NOTOPMOST (-2)

For topmost windows, places the window above all non-topmost windows (that is, behind all topmost windows). For non-topmost windows, the flag has no effect.

HWND_TOP (0)

Places the window at the top of the Z-order.

HWND_TOPMOST (-1)

Places the window above all non-topmost windows and maintains the window’s topmost position, even if it loses the focus (an option typically indicated on menus as “always on top”).

x

Equivalent to the Left property in Visual Basic.

y

Equivalent to the Top property in Visual Basic.

cx

Equivalent to the Width property in Visual Basic.

cy

Equivalent to the Height property in Visual Basic.

wFlags

Flags that specify the sizing and positioning attributes. If multiple flags are present, you can logically Or them together. Some of the possible flags are:

SWP_DRAWFRAME (32)

Draws a frame around the window.

SWP_HIDEWINDOW (128)

Hides the window.

SWP_NOACTIVATE ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.