vb 动态生成一个image后,如何点击这个image自由拖动
1个回答
展开全部
Public n
Public x1, y1
Private Sub Form_Load()
n = 0
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
n = 1
x1 = X
y1 = Y
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If n = 1 Then
Debug.Print X & "|"; Y
Image1.Top = Image1.Top + Y - y1
Image1.Left = Image1.Left + X - x1
End If
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
n = 0
End Sub
Public x1, y1
Private Sub Form_Load()
n = 0
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
n = 1
x1 = X
y1 = Y
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If n = 1 Then
Debug.Print X & "|"; Y
Image1.Top = Image1.Top + Y - y1
Image1.Left = Image1.Left + X - x1
End If
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
n = 0
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询