TizzyT

BottomMostForm -TizzyT

Sep 27th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.14 KB | None | 0 0
  1. Public Class BottomMostForm
  2.     Inherits Form
  3.  
  4.     Private Property LockZorder As Boolean = False
  5.  
  6.     Private Structure WINDOWPOS
  7.         Public hwnd As IntPtr
  8.         Public hwndInsertAfter As IntPtr
  9.         Public x As Integer
  10.         Public y As Integer
  11.         Public cx As Integer
  12.         Public cy As Integer
  13.         Public flags As UInteger
  14.     End Structure
  15.  
  16.     Public Overridable Overloads ReadOnly Property TopMost() As Boolean
  17.         Get
  18.             Return False
  19.         End Get
  20.     End Property
  21.  
  22.     Protected Overrides Sub WndProc(ByRef m As Message)
  23.         If m.Msg = &H46 AndAlso LockZorder Then
  24.             Dim Intercept As New WINDOWPOS
  25.             Intercept = Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, GetType(WINDOWPOS))
  26.             Intercept.flags = 4 Or Intercept.flags
  27.             Runtime.InteropServices.Marshal.StructureToPtr(Intercept, m.LParam, True)
  28.         End If
  29.         MyBase.WndProc(m)
  30.     End Sub
  31.  
  32.     Private Sub BottomMostForm_Shown(sender As Object, e As EventArgs) Handles Me.Shown
  33.         LockZorder = False
  34.         SendToBack()
  35.         LockZorder = True
  36.     End Sub
  37. End Class
Advertisement
Add Comment
Please, Sign In to add comment