I'm looking to get the cursor position during the main loop of my application/game.
From doing some research there appears to be two methods of doing this: Firstly listening for the WM_MOUSEMOVE event and checking the lParam. Secondly using GetCursorPos() then following it up with ScreenToClient().
I have a window which is set up to be 1680x1050, however when looking at the data that comes through from either method, I end up with a value of around 1660 at the very right side of the window.
I've not been able to find any resource which explains why this may be happening and I'm wondering whether it has anything to do with the window creation?
This is the code I am using to create the window for my application
//Register the window class WNDCLASS windowClass; windowClass = {}; windowClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = handleWindowMessages; windowClass.hInstance = hInstance; windowClass.hCursor = LoadCursor(nullptr, IDC_ARROW); windowClass.lpszClassName = L"D3D11 Rendering"; if (!RegisterClass(&windowClass)) { return 0; } //Create the window HWND windowHandle = CreateWindowEx(0, windowClass.lpszClassName, L"D3D11 Rendering", (WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) | WS_VISIBLE, //According to stackoverflow.com WS_OVERLAPPEDWINDOW ^ (XOR) WS_THICKFRAME will prevent window resizing CW_USEDEFAULT, CW_USEDEFAULT, gResolutionX, gResolutionY, 0, 0, hInstance, 0); Then in the main loop I am doing the following:
POINT p; GetCursorPos(&p); ScreenToClient(windowHandle, &p); Any pointers, tips, or information would be appreciated.
Edit: The applications window is not maximized and/or over the taskbar. The issue occurs on both axis, x and y. I had noticed that the title bar at the top keeps the y position at 0 whilst the cursor is inside it. Is there a way to get to the renderable area of the screen? When creating the window with the resolution I want my game to run at, I expect the bit in the middle (not sure on the actual terminology - the bit without the borders and the title bar) to match the resolution.