C ++ win32 set cursor position

I know which function to use, but I cannot get it to work correctly. I used SetCursorPos() , the only problem is that it sets the cursor not to the coordinates of the windows, but to the coordinates of the screen. I also tried ScreenToClient() , but it did not work with the SR.
Here is my code:

 pt.x=113; pt.y=280; ScreenToClient(hWnd, &pt); SetCursorPos(pt.x, pt.y); 

any idea? I am using win32. Hope I have given enough information.

+4
source share
1 answer

You are approaching this a little back. The SetCursorPos function works on screen networks, and you want to set the cursor based on the coordinates of the window / client. To do this, you need to display from the client to the screen coordinates. The ScreenToClient function does the opposite. What you are looking for is ClientToScreen

For instance:

 ClientToScreen(hWnd, &pt); SetCursorPos(pt.x,pt.y); 

Documentation

+11
source

All Articles