SetWindowPos (user32)
Last changed: Ozymandius257-86.25.164.114

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
   int Y, int cx, int cy, uint uFlags);

VB Signature:

<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, _
                      ByVal hWndInsertAfter As IntPtr, _
                      ByVal X As Integer, _
                      ByVal Y As Integer, _
                      ByVal cx As Integer, _
                      ByVal cy As Integer, _
                      ByVal uFlags As UInt32) As Boolean
End Function

VB.NET Signature:

Declare Auto Function SetWindowPos Lib "user32" (ByVal hWnd As IntPtr, _
                      ByVal hWndInsertAfter As IntPtr, _
                      ByVal X As Integer, _
                      ByVal Y As Integer, _
                      ByVal cx As Integer, _
                      ByVal cy As Integer, _
                      ByVal uFlags As UInteger) As Boolean

User-Defined Types:

static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);

static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);

static readonly IntPtr HWND_TOP = new IntPtr(0);

static readonly IntPtr HWND_BOTTOM = new IntPtr(1);

ReadOnly HWND_BOTTOM As New IntPtr(1)

ReadOnly HWND_NOTOPMOST As New IntPtr(-2)

ReadOnly HWND_TOP As New IntPtr(0)

ReadOnly HWND_TOPMOST As New IntPtr(-1)

// Values for the uFlags parameter

//From winuser.h

const UInt32 SWP_NOSIZE = 0x0001;

const UInt32 SWP_NOMOVE = 0x0002;

const UInt32 SWP_NOZORDER = 0x0004;

const UInt32 SWP_NOREDRAW = 0x0008;

const UInt32 SWP_NOACTIVATE = 0x0010;

const UInt32 SWP_FRAMECHANGED = 0x0020; /* The frame changed: send WM_NCCALCSIZE */

const UInt32 SWP_SHOWWINDOW = 0x0040;

const UInt32 SWP_HIDEWINDOW = 0x0080;

const UInt32 SWP_NOCOPYBITS = 0x0100;

const UInt32 SWP_NOOWNERZORDER = 0x0200; /* Don't do owner Z ordering */

const UInt32 SWP_NOSENDCHANGING = 0x0400; /* Don't send WM_WINDOWPOSCHANGING */

Notes:

HWND_TOP will bring a window to the front of the Z-Order only if the thread is in the foreground. Otherwise it will bring the window to the front of the thread's Z-order.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation