2个回答
展开全部
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static X1 As Long, Y1 As Long, X2 As Long, Y2 As Long
Select Case Button
Case 1 '左键
If X1 = 0 And Y1 = 0 Then '如果是第一次点击
X2 = X '记录第一次点击坐标
Y2 = Y
Else
Me.Line (X1, Y1)-(X, Y), vbRed '不是第一次点击,连线
End If
Case 2 '鼠标右键
Me.Line (X1, Y1)-(X2, Y2), vbRed
X1 = 0
Y1 = 0
Exit Sub
End Select
X1 = X '记录本次点击坐标
Y1 = Y
End Sub
Static X1 As Long, Y1 As Long, X2 As Long, Y2 As Long
Select Case Button
Case 1 '左键
If X1 = 0 And Y1 = 0 Then '如果是第一次点击
X2 = X '记录第一次点击坐标
Y2 = Y
Else
Me.Line (X1, Y1)-(X, Y), vbRed '不是第一次点击,连线
End If
Case 2 '鼠标右键
Me.Line (X1, Y1)-(X2, Y2), vbRed
X1 = 0
Y1 = 0
Exit Sub
End Select
X1 = X '记录本次点击坐标
Y1 = Y
End Sub
展开全部
Dim oldX, oldY, x0, y0
Private Sub Form_Load()
oldX = -1
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If oldX >= 0 Then
Me.Line (oldX, oldY)-(X, Y)
Else
x0 = X
y0 = Y
End If
oldX = X
oldY = Y
Else
Me.Line (x0, y0)-(oldX, oldY)
End If
End Sub
Private Sub Form_Load()
oldX = -1
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If oldX >= 0 Then
Me.Line (oldX, oldY)-(X, Y)
Else
x0 = X
y0 = Y
End If
oldX = X
oldY = Y
Else
Me.Line (x0, y0)-(oldX, oldY)
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询