小弟写了个vb程序,功能很简单,当鼠标移动到图片框中时鼠标旁边显示鼠标的坐标,再通过单击获得几个点,连起来形成一条直线,下面是我写的代码:
Dim a(10) As Integer, b(10) As Integer
Dim t As Integer
Private Sub Form_Load()
t = 0
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Visible = False
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Cls
a(t) = X: b(t) = Y
t = t + 1
If t > 1 Then
For i = 0 To t - 2
Picture1.Line (a(i), b(i))-(a(i + 1), b(i + 1))
Next
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Visible = True
Label1.Left = X
Label1.Top = Y - 10
Label1.Caption = Str(X) + "," + Str(Y)
End Sub
可运行这个程序的时候只显示鼠标坐标,单击时不画线,如果我把mousemove这个事件去掉就可以画线了,难道是mousedown这个事件没触发?百思不得其解,望大虾们指点~~~感激不尽~~