您的位置:首页 > 编程语言

无边框窗体拖动大小代码

2009-04-07 16:47 295 查看
无边框窗体拖动大小代码

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: