Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


How do you use GetCursorPos

This topic is 6723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What's there to wonder about? It's very self-explaining.

The GetCursorPos function retrieves the cursor's position, in screen coordinates.

BOOL GetCursorPos(
LPPOINT lpPoint // address of structure for cursor position





// Convert to window coordinates (from screen coordinates)
RECT window_rect;
GetWindowRect(g_hwnd, &window_rect);

pt.x -= window_rect.left;
pt.y -= window_rect.top;


// Convert to client coordinates (from window coordinates)
RECT client_rect;
GetClientRect(g_hwnd, &client_rect);

pt.x -= client_rect.left;
pt.y -= client_rect.top;

"Paranoia is the belief in a hidden order behind the visible." - Anonymous

Edited by - Staffan on June 25, 2000 5:50:43 PM

Edited by - Staffan on June 25, 2000 5:51:58 PM

Share this post

Link to post
Share on other sites
This is how I normally use it:

int mouse_x;
int mouse_y;
POINT mouse_pos;
mouse_x = mouse_pos.x;
mouse_y = mouse_pos.y;

Do you have the MSDN docs? They explain the process quite well...

- Daniel

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!