gpt4 book ai didi

winapi - GetCursorPos 只返回 x 值

转载 作者:行者123 更新时间:2023-12-01 19:44:59 25 4
gpt4 key购买 nike

我在 MSDN forum 上看到了一个帖子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

Timer1_Timer()中...

Dim mousePos As POINTAPI
Call GetCursorPos(mousePos)
MsgBox mousePos.x & " " & mousePos.y

此消息框显示鼠标 x 坐标的正确值,但无论鼠标位于屏幕上的哪个位置,它都显示 y“0” 。此外,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

或使用:

Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long 

关于winapi - GetCursorPos 只返回 x 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11287536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com