朋友们,祝元旦节快乐!我有个问题想请教下。我在图片框中自定义了坐标轴和上面的刻度,并且在坐标平面内画了曲线,运行后在生成的曲线上,我想通过鼠标单击曲线任意一点来获取坐标值,这该如何实现?望高手指点!

解决方案 »

  1.   

    Option Explicit
    Private Type POINTAPI '定义一个坐标变量
    x As Long
    y As Long
    End Type
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Sub Picture1_Click()
    Dim z As POINTAPI
    GetCursorPos z
    Text1.Text = z.x - (Form1.Left + Picture1.Left) / Screen.TwipsPerPixelX
    Text2.Text = z.y - (Form1.Top + Picture1.Top) / Screen.TwipsPerPixelY
    End Sub
      

  2.   

    LZ:可通过Picture1_MouseMove事件获取鼠标坐标值.
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Text1 = X
        Text2 = Y
    End Sub
      

  3.   

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Text1 = X
        Text2 = Y
    End Sub楼主试试就懂了