I don't wish to make this complicated, but I promise all my tests show that the following variables are not good for computing absolute screen coordinates: dims2.lX (or .lY for vertical movement), I have read many threads on this and all keep saying that they use it for correct absolute coords computation, but I am failing to see how it can possibly work.. Here is my setup: - mouse.cpp (VC8 sln from DirectX SDK) - select NONEXCL, FOREGROUND, IMMEDIATE (mouse format is c_dfDIMouse2) In the code, try this:
...
int absx=-777;
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
...
POINT pt;
pt.x = 0;
pt.y = 0;
ClientToScreen(hDlg, &pt);
SetCursorPos(pt.x, pt.y);
absx = pt.x;
if( FAILED( OnCreateDevice( hDlg ) ) )
...
// The dims structure now has the state of the mouse, so
// display mouse coordinates (x, y, z) and buttons.
//StringCchPrintf( strNewText, 128, TEXT("(X=% 3.3d, Y=% 3.3d, Z=% 3.3d) B0=%c B1=%c B2=%c B3=%c B4=%c B5=%c B6=%c B7=%c"),
// dims2.lX, dims2.lY, dims2.lZ,
// (dims2.rgbButtons[0] & 0x80) ? '1' : '0',
...
// The dims structure now has the state of the mouse, so
// display mouse coordinates (x, y, z) and buttons.
absx = absx + dims2.lX;
StringCchPrintf( strNewText, 128, TEXT("#%d#"), absx);