运行时,我需要添加许多图像在我的图片框中,我有很多图像,并希望通过picture1.line连接它。但是我需要知道起点到终点的实际坐标(在运行时)。
关于此如何读取/显示鼠标指针坐标的任何示例或想法?
在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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句