I'm working on capturing the mouse coordinates in a little game I'm making during some time off. I go to work on the ability to select different units, and I notice that my selection appears off. Upon further investigation, I can't find anything wrong with my code. So, I decide to output mouse coordinates to the screen so I can run some tests. The mouse starts at 0,0 in the top right perfectly fine. I have a small test map up, and I go to the corner of it which the game tells me is at 512,512. The mouse is telling its 508,484. So, I think maybe something is stretching my map. To test to see if maybe it's my map drawing algorithm that's off, I have a box drawn using 0,0 512,0 512,512 and 0,512 as the corners. It lines up with corners of what I have drawn, but not with the mouse.
I'm using Direct3D 9, on Windows XP. Is there any reason anyone can think of that the coordinates might be off? In the far right corner of my window it tells me the coordinates are 795,567 and I figure that's about right for an 800x600 window taking the caption/system menu bar into account and the border.
Here's how I query for my mouse coordinates:
ptCurrentMousePosit.x = LOWORD(lParam);
ptCurrentMousePosit.y = HIWORD(lParam);
// ... handle coordinates and test for selection ...
I checked MSDN and they gave me no reason to believe that the coordinates which this give me should be wrong. I use the exact same method for WM_MOUSEMOVE so I can record the mouse coordinates on the screen for testing (Source). On that source, it mentions using GET_X_LPARAM and GET_Y_LPARAM, however I've seen it done correctly the way I am doing it, and MSVC++ 2005 Express Edition complains that they don't exist even though they are supposed to be in windows.h.
My screen resolution is 1280x1024, but I doubt that has anything to do with it.
Is there any reason the drawing could be stretched or something? I don't have any reason to believe that its a projection problem, however I'm open to any and all suggestions you might have. The back buffer is the same size as the window by the way, so it isn't becuase there is a size difference between the two.
Thanks for any help in advance.