Cursor Postition
-
I have problem of finding the curson's position!! When the curson is not inside the program that I create!!!!
-
I have problem of finding the curson's position!! When the curson is not inside the program that I create!!!!
The following code gets the current mouse position :
POINT point;
GetCursorPos(&point);// point.x and point.y have the mouse position
// with respect to the entire screen
// NOT the applicationThe problem is to get this code called whenever the mouse moves. WM_MOUSEMOVE only generates messages when in the application window. The only way I have found to do it is as follows: 1) add a WM_TIMER message to your application 2) code it as follows :
void YOUR_CLASS::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call defaultCDialog::OnTimer(nIDEvent);
POINT point;
GetCursorPos(&point);// point.x and point.y have the mouse position
// with respect to the entire screen
// not the application// do whatever you want with these values
- start the timer :
SetTimer(1,200,NULL); // calls OnTimer() every 200 milliseconds