0

运行时,我需要在我的图片框中添加许多图像,我有很多图像并希望通过picture1.line 连接它。但我需要知道起点到终点的实际坐标(在运行时)。

关于如何读取/显示鼠标指针坐标的任何示例或任何想法?

4

1 回答 1

1

在 VB6 中,您可以这样做。创建一个新表单并添加以下代码:

Option Explicit

Private Type POINTAPI 'Type to hold coordinates
    X As Long
    Y As Long
End Type

'Function that gets current position
Private Declare Sub GetCursorPos Lib "User32" (lpPoint As POINTAPI)

'On mouse move, update form
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim rect As POINTAPI

    'Get position
    GetCursorPos rect

    'Print coordinates
    Me.Cls
    Print "Current X = " & rect.X
    Print "Current Y = " & rect.Y
End Sub
于 2013-07-18T07:39:10.237 回答