Jump to content
  • Advertisement
Sign in to follow this  
judeclarke

Cursor Position slowly becoming less pixel perfect when moving from origin

This topic is 1099 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

I am running into a really strange problem where the more I move away from the top-left of my windowed game the cursor position will slowly become further from the "correct" position. For example, I have an 800, 600 window that I print the mouse position to on the screen. When I move it to the bottom right of my window, it is saying the position is 784, 561.

 

I create using CreateWindowExA with WS_EX_APPWINDOW as the first parameter (extended style), and the only window syle flag is WS_VISIBLE.
 

I get the mouse position with

 

    POINT winCursorPoint;

    GetCursorPos(&winCursorPoint);

    BOOL success = ScreenToClient(mWindowHandle, &winCursorPoint);

    mCurrentMousePosition.x = winCursorPoint.x;

    mCurrentMousePosition.y = winCursorPoint.y;

 

Is there some other window creation flag or mouse positioning calculation that needs to be done?

Share this post


Link to post
Share on other sites
Advertisement

Did you take in account the window border size? The size you pass to CreateWindow(Ex) is the outer size.

 

You can use AdjustWindowRect(Ex) to calculate the outer size from a wanted client size.

Share this post


Link to post
Share on other sites
What does your coordinate-print program say?

Such programs are usually simple enough not to make silly errors with offsets, and a good way to see how things actually work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!