Option Explicit
'用于计时
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
'用于发送消息
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
'为当前的应用程序释放鼠标捕获
Private Declare Function ReleaseCapture Lib "user32" () As Long
'取得窗体位置的函数
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'取得鼠标位置的函数
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
'用于如何操纵窗体大小及其位置
Dim Action As String
'停止计时
Private ExitApp As Boolean
Private Sub Form_Load()
Me.Show
GetTime
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
ReleaseCapture
Select Case Action
Case "Left"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTLEFT, 0&
Case "Right"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTRIGHT, 0&
Case "Up"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTTOP, 0&
Case "LeftUp"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTTOPLEFT, 0&
Case "RightUp"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTTOPRIGHT, 0&
Case "Down"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTBOTTOM, 0&
Case "LeftDown"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTBOTTOMLEFT, 0&
Case "RightDown"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, 0&
Case "Move"
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Select
End If
End Sub
Private Sub frmSize()
Dim MyRect As RECT
Dim MyPoint As POINTAPI