当我在picture内画了6个点(用两条线来画的十字交点),当我把鼠标移到任何一个点(十字线交点)上时,这个点要变成红色,并且还要得到这到点的坐标(X和Y)的值。

解决方案 »

  1.   

    记录下6个点的坐标,在Form_mousemove中判断x,y坐标是否与这六个点的坐标相同,如果相同,以交点为中心画一圆啊。
      

  2.   

    Dim x1 As Integer, y1 As Integer
    Dim x2 As Integer, y2 As Integer
    Dim j As Integer
    Dim i As Integer
    Dim array1(1 To 2, 1 To 6) As Integer  '用来记录所点6个点的坐标
    Private Sub Form_Load()
    Picture1.ScaleMode = 3
    End Sub
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    i = i + 1
    If i > 6 Then
        MsgBox "你已经输入了6个点"
        Exit Sub
    End If
    Picture1.Line (X - 5, Y - 5)-(X + 5, Y + 5), QBColor(11)'用两条交叉线显示点的位置
    Picture1.Line (X - 5, Y + 5)-(X + 5, Y - 5), QBColor(11)
    array1(1, i) = X: array1(2, i) = Y
    End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If i > 6 Then
        For j = 1 To 6
          If X = array1(1, j) And Y = array1(2, j) Then
             Picture1.PSet (X, Y), RGB(255, 0, 0)   '一个点用pset是看不出来慢的
             Text1.Text = X: Text2.Text = Y
          End If
        Next j
    Else
        Exit Sub
    End If
    End Sub上面的代码可以满足你的要求,不过哪个红点好小啊,你自己看看要不要画个圆之类的一提高可视度。当然,还要根据你自己的实际情况作相应的修改啊。