In C++ (WIN32), how can I get the (X,y) coordinate of a mouse click on the screen?
Assuming the plain Win32 API, use this in your handler for WM_LBUTTONDOWN
:
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
You can call GetMouseMovePointsEx to get the mouse position and history. Alternatively, if you have access to your wndproc, you can just check the lparam of WM_MOUSEMOVE, WM_LBUTTONDOWN or similar message for the x,y coordinates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With