关于 GetCurrentPos() 返回 false 的确切原因,以及它能否精确定位鼠标位置?

roy 2005-08-31 01:57:45
同题。
...全文
251 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
weiym 2005-09-01
  • 打赏
  • 举报
回复
POINT pt
if(GetCursorPos(&pt) ==FALSE)
DWORD err = GetLastError();
得到这个err再去查询到底出了什么错误,使用MSDN或VC错误查询工具
======
可以用FormatMessage函数看具体的错误信息
roy 2005-08-31
  • 打赏
  • 举报
回复
第二个问题,它定位的应该是 光标 但大部分时候可以用来定位鼠标位置,其出现不符的时候应该在什么状态?
windcsn 2005-08-31
  • 打赏
  • 举报
回复
POINT pt
if(GetCursorPos(&pt) ==FALSE)
DWORD err = GetLastError();
得到这个err再去查询到底出了什么错误,使用MSDN或VC错误查询工具
wwjokwang 2005-08-31
  • 打赏
  • 举报
回复
POINT pt
GetCursorPos(&pt);
ScreenToClient(pt);
快乐鹦鹉 2005-08-31
  • 打赏
  • 举报
回复
有MSDN为证:
GetCursorPos
The GetCursorPos function retrieves the cursor's position, in screen coordinates.

BOOL GetCursorPos(
LPPOINT lpPoint // cursor position
);
Parameters
lpPoint
[out] Pointer to a POINT structure that receives the screen coordinates of the cursor.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

最后一段写的很清楚,如果函数返回false,那么可以调用GetLastError来获取错误信息。
roy 2005-08-31
  • 打赏
  • 举报
回复
确实是我笔误写错了 应该是 GetCursorPos,

还有就是, happyparrot 讲的太朦胧,能不能详细点
GetLastError能得到GetCursorPos() == false 的原因?这并不是系统错误啊?若能得到能不能贴出部分代码
windcsn 2005-08-31
  • 打赏
  • 举报
回复
使用GetLastError来得到错误
快乐鹦鹉 2005-08-31
  • 打赏
  • 举报
回复
关于 GetCurrentPos() 返回 false 的确切原因
==用GetLastError()即可查看原因。

以及它能否精确定位鼠标位置
==肯定是屏幕坐标。与映射关系无关。
The cursor position is always specified in screen coordinates and is not affected by the mapping mode of the window that contains the cursor.

windcsn 2005-08-31
  • 打赏
  • 举报
回复
GetCursorPos
快乐鹦鹉 2005-08-31
  • 打赏
  • 举报
回复
GetCurrentPos() ???没听说过这个函数。MSDN也没有阿

15,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧