您的位置:首页 > 编程语言 > C语言/C++

Window 显示鼠标的坐标

2016-07-05 01:42 337 查看

Window 显示鼠标的坐标

GetCursorPos(POINT *p)函数

windows.h头文件里面的GetCursorPos(POINT *p)函数是用来获取鼠标在屏幕中的坐标信息的。

GetCursorPos(POINT *p)函数的使用实例

#include <iostream>
#include<windows.h>

int main(){

while(1){
POINT p;//定义一个POINT变量,用于存储鼠标的坐标
GetCursorPos(&p);//获取鼠标位置
std::cout << "当前的鼠标坐标为:x:" << p.x << ", y:" << p.y << ". " << std::endl;
}
return 0;
}


SetCursorPos(int x, int y)函数

windows.h头文件里面的SetCursorPos(int x, int y)函数是用来设置鼠标在屏幕中的坐标位置的。

SetCursorPos(int x, int y)函数的使用实例

待续

参考网站:

http://blog.inet198.cn/?yali_xunzhen/article/details/50810618

http://zhidao.baidu.com/question/182223453.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息