![](/img/trans.png)
[英]How to print sentence in the position of the mouse cursor in VC++ Win32 application?
[英]How to print mouse coordinates in VC++ Win32 application?
我知道有一个函数GetCursorPos
和WM_MOUSEMOVE
事件,但任何人都可以通过示例代码告诉我如何最好地打印鼠标坐标? 我不确定如何在VC ++中执行此操作。
如前所述,您可以使用GetCursorPos
获取鼠标光标在屏幕上的瞬时位置。 这是一个示例:
POINT pt;
if (!GetCursorPos(&pt)) {
/* ... handle the error ... */
}
您需要#include <windows.h>
才能使用此代码。 调用函数后,您可以从pt.x
和pt.y
读取鼠标坐标。
希望这可以帮助!
试试这个,让我知道。
POINT coord;
GetCursorPos(&coord);
cout << "The mouse is at:" << coord.x << coord.y << endl;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.