7个回答
展开全部
我这里有不用API的:
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST& = -1 ' 将窗口置于列表顶部,并位于任何最顶部窗口的前面
Private Const SWP_NOSIZE& = &H1 ' 保持窗口大小
Private Const SWP_NOMOVE& = &H2 ' 保持窗口位置
Dim MX As Integer
Dim MY As Integer
Dim MDown As Boolean
Private Sub label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MDown = True
MX = X
MX = Y
End Sub
Private Sub label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If MDown = True Then
If Button = 1 Then
MX = X - MX
MY = Y - MY
Me.Move Me.Left + (X - MX), Me.Top + (Y - MY)
End If
End If
End Sub
Private Sub label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MDown = False
End Sub
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST& = -1 ' 将窗口置于列表顶部,并位于任何最顶部窗口的前面
Private Const SWP_NOSIZE& = &H1 ' 保持窗口大小
Private Const SWP_NOMOVE& = &H2 ' 保持窗口位置
Dim MX As Integer
Dim MY As Integer
Dim MDown As Boolean
Private Sub label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MDown = True
MX = X
MX = Y
End Sub
Private Sub label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If MDown = True Then
If Button = 1 Then
MX = X - MX
MY = Y - MY
Me.Move Me.Left + (X - MX), Me.Top + (Y - MY)
End If
End If
End Sub
Private Sub label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MDown = False
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private
sub
command3_click()
form1.left
=
form1.left
+
500
'每单击一次按钮,窗体向右移动500个单位
end
sub
private
sub
command4_click()
form1.top
=
form1.top
+
500
'每单击一次按钮,窗体向下移动500个单位
end
sub
sub
command3_click()
form1.left
=
form1.left
+
500
'每单击一次按钮,窗体向右移动500个单位
end
sub
private
sub
command4_click()
form1.top
=
form1.top
+
500
'每单击一次按钮,窗体向下移动500个单位
end
sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function ReleaseCapture Lib "user32" () 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) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
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) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private
Sub
Command1_Click()
Form1.Left
=
Form1.Left
+
Val(Text1.Text)
End
Sub
Private
Sub
Command2_Click()
Form1.Top
=
Form1.Top
+
Val(Text2.Text)
End
Sub
Private
Sub
Command3_Click()
Form1.Left
=
Form1.Left
+
Val(Text1.Text)
Form1.Top
=
Form1.Top
+
Val(Text2.Text)
End
Sub
Sub
Command1_Click()
Form1.Left
=
Form1.Left
+
Val(Text1.Text)
End
Sub
Private
Sub
Command2_Click()
Form1.Top
=
Form1.Top
+
Val(Text2.Text)
End
Sub
Private
Sub
Command3_Click()
Form1.Left
=
Form1.Left
+
Val(Text1.Text)
Form1.Top
=
Form1.Top
+
Val(Text2.Text)
End
Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把代码放在form的mousemove
事件里不过这是个下下策,虽然不能100%解决你的问题,但你可以试试!
事件里不过这是个下下策,虽然不能100%解决你的问题,但你可以试试!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询