Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SetWindowPos (user32)
 
.
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 UInteger) 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)

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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions