无边框窗体拖动大小代码 VB.NET Code Const WM_NCHITTEST As Integer = &H84 Const HTLEFT As Integer = 10 Const HTRIGHT As Integer = 11 Const HTTOP As Integer = 12 Const HTTOPLEFT As Integer = 13 Const HTTOPRIGHT As Integer = 14 Const HTBOTTOM As Integer = 15 Const HTBOTTOMLEFT As Integer = &H10 Const HTBOTTOMRIGHT As Integer = 17 Protected Overloads Overrides Sub WndProc(ByRef m As Message) MyBase.WndProc(m) Select Case m.Msg Case WM_NCHITTEST Dim vPoint As New Point(CInt(m.LParam) And &HFFFF, CInt(m.LParam) >> 16 And &HFFFF) vPoint = PointToClient(vPoint) If vPoint.X <= 5 Then If vPoint.Y <= 5 Then m.Result = CType(HTTOPLEFT, IntPtr) ElseIf vPoint.Y >= ClientSize.Height - 5 Then m.Result = CType(HTBOTTOMLEFT, IntPtr) Else m.Result = CType(HTLEFT, IntPtr) End If ElseIf vPoint.X >= ClientSize.Width - 5 Then If vPoint.Y <= 5 Then m.Result = CType(HTTOPRIGHT, IntPtr) ElseIf vPoint.Y >= ClientSize.Height - 5 Then m.Result = CType(HTBOTTOMRIGHT, IntPtr) Else m.Result = CType(HTRIGHT, IntPtr) End If ElseIf vPoint.Y <= 5 Then m.Result = CType(HTTOP, IntPtr) ElseIf vPoint.Y >= ClientSize.Height - 5 Then m.Result = CType(HTBOTTOM, IntPtr) End If Exit Select End Select End Sub