C++获取鼠标位置,移动鼠标
生活随笔
收集整理的這篇文章主要介紹了
C++获取鼠标位置,移动鼠标
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
獲取鼠標(biāo)位置:
函數(shù)原型:
WINUSERAPI BOOL WINAPI GetCursorPos(__out LPPOINT lpPoint);WINUSERAPI BOOL WINAPI GetPhysicalCursorPos(__out LPPOINT lpPoint);案例(MFC)
POINT p;CString strPos, strCaption;GetCursorPos(&p);strPos.Format(_T("<%d, %d>"), p.x, p.y);//GetWindowTextW(strCaption);strCaption =_T("位置-") + strPos;this->SetWindowTextW(strCaption);移動鼠標(biāo)位置:
函數(shù)原型:
WINUSERAPI HCURSOR WINAPI SetCursor(__in_opt HCURSOR hCursor);WINUSERAPI BOOL WINAPI SetPhysicalCursorPos(__in int X, __in int Y);案例:
#include <iostream>#include <windows.h>int main(){POINT p, pNext; GetCursorPos(&p);SetCursorPos(p.x + 30, p.y + 30);GetCursorPos(&pNext);std::cout<< pNext.x<<","<<pNext.y<<endl;return 0;}總結(jié)
以上是生活随笔為你收集整理的C++获取鼠标位置,移动鼠标的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 001+limou+C语言入门知识——(
- 下一篇: 2017年电大计算机应用基础试题及答案,