3个回答
展开全部
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal lhwnd As Long, ByVal hWndInsertAfter As Long, ByVal swpX As Long, ByVal swpY As Long, ByVal cX As Long, ByVal cY As Long, ByVal wFlags As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngReturnValue As Long
If Button = 1 Then
Call ReleaseCapture
lngReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
If Me.Left >= Screen.Width - (Me.Width * 0.9) Then
Me.Left = Screen.Width - Me.Width
Else
If Me.Left <= -(Me.Width * 0.1) Then
Me.Left = 0
End If
End If
If Me.Top >= Screen.Height - (Me.Height * 0.9) Then
Me.Top = Screen.Height - Me.Height
Else
If Me.Top <= -(Me.Height * 0.1) Then
Me.Top = 0
End If
End If
End Sub
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal lhwnd As Long, ByVal hWndInsertAfter As Long, ByVal swpX As Long, ByVal swpY As Long, ByVal cX As Long, ByVal cY As Long, ByVal wFlags As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngReturnValue As Long
If Button = 1 Then
Call ReleaseCapture
lngReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
If Me.Left >= Screen.Width - (Me.Width * 0.9) Then
Me.Left = Screen.Width - Me.Width
Else
If Me.Left <= -(Me.Width * 0.1) Then
Me.Left = 0
End If
End If
If Me.Top >= Screen.Height - (Me.Height * 0.9) Then
Me.Top = Screen.Height - Me.Height
Else
If Me.Top <= -(Me.Height * 0.1) Then
Me.Top = 0
End If
End If
End Sub
展开全部
Private Const WM_NCLBUTTONDOWN = &HA1
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 ReleaseCapture Lib "user32" () As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, 2, 0
End Sub
这样就可以了
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 ReleaseCapture Lib "user32" () As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, 2, 0
End Sub
这样就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
只有用代码移动了。
form1.move 坐标值
form1.move 坐标值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询