I had a problem when Minimize and maximize the program from the taskbar icon . Where is the form without Border? When I put the code to Minimize and maximize the program from the taskbar icon , it works without problems. When I put the form extension code in all direction with Minimize and maximize code, the form extension code does not work, but only Minimize and maximize works.
Extension code: I mean increasing the width and height of the form by dragging the mouse from the edge inward or outward.
'Minimize and maximize the program from the taskbar icon form
Protected Overrides ReadOnly Property CreateParams As CreateParams
Get
Dim CPa As CreateParams = MyBase.CreateParams
CPa.Style = CPa.Style Or &HA0000
Return (CPa)
End Get
End Property
'form extension
Private Const WM_NCHITTEST As Integer = &H84
Private Const WM_MOUSEMOVE As Integer = &H200
Private Const WM_LBUTTONDOWN As Integer = &H201
'Private Const WM_LBUTTONUP As Integer = &H202
Private Const MK_LBUTTON As Integer = &H1
Private Const HTLEFT As Integer = &HA
Private Const HTRIGHT As Integer = &HB
Private Const HTTOP As Integer = &HC
Private Const HTTOPLEFT As Integer = &HD
Private Const HTTOPRIGHT As Integer = &HE
Private Const HTBOTTOM As Integer = &HF
Private Const HTBOTTOMLEFT As Integer = &H10
Private Const HTBOTTOMRIGHT As Integer = &H11
Private OffSet As Point = Point.Empty
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_NCHITTEST Then
Dim loc As New Point(m.LParam.ToInt32 And &HFFFF, m.LParam.ToInt32 >> 16)
loc = PointToClient(loc)
Dim bTop As Boolean = (loc.Y < ClientRectangle.Y + 4)
Dim bLeft As Boolean = (loc.X < ClientRectangle.X + 4)
Dim bRight As Boolean = (loc.X > Width - 4)
Dim bBottom As Boolean = (loc.Y > Height - 4)
If bTop AndAlso bLeft Then
m.Result = CType(HTTOPLEFT, IntPtr)
Return
ElseIf bTop AndAlso bRight Then
m.Result = CType(HTTOPRIGHT, IntPtr)
Return
ElseIf bBottom AndAlso bLeft Then
m.Result = CType(HTBOTTOMLEFT, IntPtr)
Return
ElseIf bBottom AndAlso bRight Then
m.Result = CType(HTBOTTOMRIGHT, IntPtr)
Return
ElseIf bLeft Then
m.Result = CType(HTLEFT, IntPtr)
Return
ElseIf bTop Then
m.Result = CType(HTTOP, IntPtr)
Return
ElseIf bRight Then
m.Result = CType(HTRIGHT, IntPtr)
Return
ElseIf bBottom Then
m.Result = CType(HTBOTTOM, IntPtr)
Return
End If
ElseIf m.Msg = WM_LBUTTONDOWN Then
OffSet = New Point(MousePosition.X - Me.Location.X, MousePosition.Y - Me.Location.Y)
ElseIf m.Msg = WM_MOUSEMOVE AndAlso m.WParam.ToInt32 = MK_LBUTTON Then
Me.Location = New Point(MousePosition.X - OffSet.X, MousePosition.Y - OffSet.Y)
End If
MyBase.WndProc(m)
End Sub