Tim*_*ery 3 vb6 winapi cursor-position
我在MSDN论坛上看到一个线程,其中存在32位与64位整数的问题.我不确定这是不是我的问题,但好像这段代码应该有用,所以我有点困惑.
我在Windows 7 64位的兼容模式(XP SP2)中运行VB6.
Type POINTAPI ' This holds the logical cursor information
x As Integer
y As Integer
End Type
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Run Code Online (Sandbox Code Playgroud)
在Timer1_Timer()
......
Dim mousePos As POINTAPI
Call GetCursorPos(mousePos)
MsgBox mousePos.x & " " & mousePos.y
Run Code Online (Sandbox Code Playgroud)
此消息框显示了鼠标的x坐标正确的值,但它表明"0"
了y
,无论在哪里鼠标在屏幕上.还有,GetCursorPos()
回来了1
.
在VB6中,整数数据类型是一个16位数字.您必须使用Long,因为这是一个32位数字.
Type POINTAPI ' This holds the logical cursor information
x As Long
y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Run Code Online (Sandbox Code Playgroud)
或使用:
Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2085 次 |
最近记录: |