views:

137

answers:

1

i know wat function to use but i can't get it to workd right. i use SetCursorPos() the only problem is that it sets the cursor not to the windows coordinates but to the screen coordinates. i also tried the ScreenToClient() but it didn't work ethier.
here is my code

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

any idea? im also using win32. i hope i gave enough information

+1  A: 

You're approaching this slightly backwards. The SetCursorPos function works in screen cordinates and you want to set the cursor based on window / client coordinates. In order to do this you need to map from client to screen coordinates. The function ScreenToClient does the opposite. What you're looking for is ClientToScreen

For example:

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

Documentation

JaredPar