'移动无规则窗口,并设有保持窗口不移出屏幕的功能
Private Declare Fun(百度傻)ction ReleaseCapture Lib "user32" () As Long
Private Declare Fun(百度傻)ction SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Sub MoveWindow(Frm As Form)
On Error GoTo ccc
ReleaseCapture
SendMessage Frm.hwnd, &HA1, 2, 0
If Frm.Top <= 500 Or Frm.Top < 0 Then Frm.Top = 0
If Frm.Top >= Screen.Height - Frm.Height Or Frm.Top >= Screen.Height - Frm.Height - 500 Then Frm.Top = Screen.Height - Frm.Height
If Frm.Left < 0 Or Frm.Left <= 500 Then Frm.Left = 0
If Frm.Left >= Screen.Width - Frm.Width Or Frm.Left >= Screen.Width - Frm.Width - 500 Then Frm.Left = Screen.Width - Frm.Width
ccc:
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveWindow Me
End Sub
Private Declare Fun(百度傻)ction ReleaseCapture Lib "user32" () As Long
Private Declare Fun(百度傻)ction SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Sub MoveWindow(Frm As Form)
On Error GoTo ccc
ReleaseCapture
SendMessage Frm.hwnd, &HA1, 2, 0
If Frm.Top <= 500 Or Frm.Top < 0 Then Frm.Top = 0
If Frm.Top >= Screen.Height - Frm.Height Or Frm.Top >= Screen.Height - Frm.Height - 500 Then Frm.Top = Screen.Height - Frm.Height
If Frm.Left < 0 Or Frm.Left <= 500 Then Frm.Left = 0
If Frm.Left >= Screen.Width - Frm.Width Or Frm.Left >= Screen.Width - Frm.Width - 500 Then Frm.Left = Screen.Width - Frm.Width
ccc:
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveWindow Me
End Sub