VB 如何实现鼠标左键拖动画矩形,并标注主对角线的坐标
2个回答
展开全部
'VB通过拖动鼠标画矩形,并且标注对角坐标
Dim Px As Single
Dim Py As Single
Dim flag As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.AutoRedraw = False
Px = X
Py = Y
flag = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flag And Button = vbLeftButton Then
Me.Refresh
Line (Px, Py)-(X, Y), , B
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flag And Button = vbLeftButton Then
Me.AutoRedraw = True
Line (Px, Py)-(X, Y), , B
flag = False
Me.CurrentX = Px
Me.CurrentY = Py
Print "(" & Px & "," & Py & ")"
Me.CurrentX = X
Me.CurrentY = Y
Print "(" & X & "," & Y & ")"
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询