当运行时,我需要添加许多图像在我的图片框上,我有很多图像,并希望通过picture1.line连接它。 但我需要知道起点到终点的实际坐标(在运行时间内)。
关于如何读取/显示鼠标指针坐标的任何示例或任何想法?
答案 0 :(得分: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