I created a mouse hook. I wanted to get the coordinates of the mouse click, but GET_X_LPARAM () gives me a negative value (and always the same when you click on different places). My problem is solved using GetCursorPos (), but I wonder why it does not work with GET_X_LPARAM / GET_Y_LPARAM. Here is the code:
LRESULT CALLBACK Recorder::mouseHook( int code, WPARAM wParam, LPARAM lParam ) { if( code < 0 ) return CallNextHookEx( m_mouseHook, code, wParam, lParam ); switch( wParam ) { case WM_LBUTTONDOWN:{ int _hereIsANegativeNumber = GET_X_LPARAM( lParam ); break;} } return CallNextHookEx( 0, code, wParam, lParam ); }
This is how I set the hook:
m_mouseHook = SetWindowsHookEx( WH_MOUSE_LL, &mouseHook, GetModuleHandle( NULL ), 0 );
source share