Title | Send a window to the top or bottom in Visual Basic .NET |
Description | This example shows how to send a window to the top or bottom in Visual Basic .NET. |
Keywords | send window to bottom, send window to top, to top, to bottom, Visual Basic .NET, VB.NET |
Categories | Controls, API |
|
<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
ReadOnly HWND_BOTTOM As New IntPtr(1)
ReadOnly HWND_TOP As New IntPtr(0)
Private Const SWP_NOSIZE As UInt32 = &H1
Private Const SWP_NOMOVE As UInt32 = &H2
Private Sub btnSendToBottom_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnSendToBottom.Click
Dim flags As UInt32 = SWP_NOMOVE Or SWP_NOSIZE
SetWindowPos(Me.Handle, HWND_BOTTOM, 0, 0, 0, 0, flags)
End Sub
Private Sub btnBringToTop_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnBringToTop.Click
Dim flags As UInt32 = SWP_NOMOVE Or SWP_NOSIZE
SetWindowPos(Me.Handle, HWND_TOP, 0, 0, 0, 0, flags)
End Sub
|