Sign in to follow this  
SelethD

How to obtain correct mouse coordinates

Recommended Posts

I have an app that is in windowed mode. Im using the commands... POINT p; GetCursorPos(&p); to get the cursor position, however its giving me the position relative to the top left corner of the desktop, not the top left corner of my app's window. So I tried this RECT WindowBounds; GetWindowRect(hWnd, &WindowBounds ); POINT p; GetCursorPos(&p) p.x = p.x - WindowBounds.left; p.y = p.y - WindowBounds.top; This almost gives me the correct mouse coords execpt that its still off by the width of the app window's title bar, in the y value and the app window's left border width in the x value. So is there any way of obtaining the heigth of the window title bar, and the width of the left border? Or is there just an easier way of doing this altogether? Thanks im using VC.net with winXP Thanks

Share this post


Link to post
Share on other sites
Will that affect the coords if im in full screen mode?

Like, can I put that in my mouse class and whether im in windowed or full screen will it give the correct coords?


and thanks for the quick reply.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this