1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Public MustInherit Class CLFWAddAttachedForm
Private Declare Function SetParent Lib "user32" ( _
ByVal hWndChild As IntPtr, _
ByVal hWndNewParent As IntPtr) As Integer
Public Sub New()
InitializeComponent()
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.ShowInTaskbar = False
End Sub
Private Enum WIN32
#Region "Window Extended Styles"
WS_EX_DLGMODALFRAME = &H1
WS_EX_NOPARENTNOTIFY = &H4
WS_EX_TOPMOST = &H8
WS_EX_ACCEPTFILES = &H10
WS_EX_TRANSPARENT = &H20
WS_EX_MDICHILD = &H40
WS_EX_TOOLWINDOW = &H80
WS_EX_NOACTIVATE = &H8000000
WS_EX_WINDOWEDGE = &H100
WS_EX_CLIENTEDGE = &H200
WS_EX_CONTEXTHELP = &H400
WS_EX_RIGHT = &H1000
WS_EX_LEFT = &H0
WS_EX_RTLREADING = &H2000
WS_EX_LTRREADING = &H0
WS_EX_LEFTSCROLLBAR = &H4000
WS_EX_RIGHTSCROLLBAR = &H0
WS_EX_CONTROLPARENT = &H10000
WS_EX_STATICEDGE = &H20000
WS_EX_APPWINDOW = &H40000
WS_EX_OVERLAPPEDWINDOW = &H300
WS_EX_PALETTEWINDOW = &H188
WS_EX_LAYERED = &H80000
#End Region
End Enum
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim p As CreateParams = MyBase.CreateParams
p.ExStyle = p.ExStyle Or (WIN32.WS_EX_NOACTIVATE Or WIN32.WS_EX_TOOLWINDOW Or WIN32.WS_EX_TOPMOST)
p.Parent = IntPtr.Zero
Return p
End Get
End Property
Private Declare Function ShowWindow Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal nCmdShow As Integer) As Integer
Public _ParentForm As Form
Public Sub Attach(ByVal IParentForm As Form)
_ParentForm = IParentForm
AddHandler _ParentForm.SizeChanged, AddressOf TrackParent
AddHandler _ParentForm.Move, AddressOf TrackParent
ShowWindow(MyBase.Handle, 1)
TrackParent(Nothing, Nothing)
End Sub
Private Sub TrackParent(ByVal sender As Object, ByVal e As EventArgs)
Me.Width = _ParentForm.ClientRectangle.Width
Me.Height = _ParentForm.ClientRectangle.Height
Me.Location = _ParentForm.PointToScreen(New Point(0, 0))
End Sub
End Class |
Partager