先把部分代码贴上来吧,有空好好整理整理,呵呵。
Public Class Form1 Declare Sub ReleaseCapture Lib "User32.dll" () Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _ (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32 Private Const WM_SYSCOMMAND = &H112 Private Const SC_MOVE = &HF010 '移动 Private Const SC_SIZE = &HF000& '改变大小 Private Const HTCAPTION = &H2 '拖动标题 '拖动的边界 Private Const SIZE_LEFT = 1 Private Const SIZE_RIGHT = 2 Private Const SIZE_TOP = 3 Private Const SIZE_TOP_LEFT = 4 Private Const SIZE_TOP_RIGHT = 5 Private Const SIZE_BOTTOM = 6 Private Const SIZE_BOTTOM_LEFT = 7 Private Const SIZE_BOTTOM_RIGHT = 8 '获得与释放窗口句柄 Private Declare Auto Function GetWindowDC Lib "user32.dll" (ByVal hWnd As IntPtr) As IntPtr Private Declare Auto Function ReleaseDC Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal hdc As IntPtr) As IntPtr Dim LeftResize, RightResize, BottomResize, TopResize As Boolean '用于调整大小的变量 Dim LeftRect, RightRect, BottomRect, TopRect As Rectangle Dim x, y As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None End Sub '判断鼠标位置,以便处理拖动边框改变窗体大小事件 Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseDown(e) x = e.X : y = e.Y If Me.MaximizeBox Then If LeftRect.Contains(e.X, e.Y) Then LeftResize = True : BottomResize = False : RightResize = False ElseIf BottomRect.Contains(e.X, e.Y) Then BottomResize = True : LeftResize = False : RightResize = False ElseIf RightRect.Contains(e.X, e.Y) Then LeftResize = False : BottomResize = False : RightResize = True Else LeftResize = False : BottomResize = False : RightResize = False End If End If End Sub '处理鼠标形状 Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseMove(e) If Me.MaximizeBox Then If e.Button = Windows.Forms.MouseButtons.Left Then '拖动边框改变窗体大小 ReleaseCapture() If LeftRect.Contains(e.X, e.Y) Then SendMessage(Me.Handle, WM_SYSCOMMAND, SC_SIZE + SIZE_LEFT, 0) If RightRect.Contains(e.X, e.Y) Then SendMessage(Me.Handle, WM_SYSCOMMAND, SC_SIZE + SIZE_RIGHT, 0) If BottomRect.Contains(e.X, e.Y) Then SendMessage(Me.Handle, WM_SYSCOMMAND, SC_SIZE + SIZE_BOTTOM, 0) If TopRect.Contains(e.X, e.Y) Then SendMessage(Me.Handle, WM_SYSCOMMAND, SC_SIZE + SIZE_TOP, 0) Else If Not Me.WindowState = FormWindowState.Maximized Then If LeftRect.Contains(e.X, e.Y) Then Me.Cursor = Cursors.SizeWE ElseIf BottomRect.Contains(e.X, e.Y) Then Me.Cursor = Cursors.SizeNS ElseIf RightRect.Contains(e.X, e.Y) Then Me.Cursor = Cursors.SizeWE ElseIf TopRect.Contains(e.X, e.Y) Then Me.Cursor = Cursors.SizeNS Else Me.Cursor = Cursors.Arrow End If Else Me.Cursor = Cursors.Arrow End If End If Else Me.Cursor = Cursors.Arrow End If End Sub '处理鼠标拖动边框改变窗体大小事件 Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseUp(e) If Me.MaximizeBox Then If e.Button = Windows.Forms.MouseButtons.Left AndAlso Not Me.WindowState = FormWindowState.Maximized Then If LeftResize Then Me.SetBounds(Me.Location.X + e.X - x, Me.Location.Y, Me.Bounds.Width - (e.X - x), Me.Bounds.Height) ElseIf BottomResize Then Me.Size = New Size(Me.Bounds.Width, Me.Bounds.Height + e.Y - y) ElseIf RightResize Then Me.Size = New Size(Me.Bounds.Width + e.X - x, Me.Bounds.Height) End If End If End If End Sub '窗体改变大小,处理一些位置信息 Private Sub SkinForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize LeftRect = New Rectangle(0, 0, 2, Me.Bounds.Height) BottomRect = New Rectangle(0, Me.Bounds.Height - 2, Me.Bounds.Width, 2) RightRect = New Rectangle(Me.Bounds.Width - 2, 0, 2, Me.Bounds.Height) TopRect = New Rectangle(0, 0, Me.Bounds.Width, 2) End Sub '绘制窗体左、右、底部边框 Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) End Sub End Class