In C++ (WIN32), how can I get the (X,y) coordinate of a mouse click on the screen?
views:
259answers:
3
+1
A:
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.
Andrew Keith
2009-12-07 01:31:00
+1
A:
Visual C++:
System::Windows::Forms::Control::MousePosition
System::Windows::Forms::Cursor:: Position
C++:
Ambrosia
2009-12-07 01:33:15
+3
A:
Assuming the plain Win32 API, use this in your handler for WM_LBUTTONDOWN
:
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
Georg Fritzsche
2009-12-07 01:33:30
This is the correct answer because it tells you where the mouse *was* when the user clicked, instead of where it *is* when you process the message (it might have moved).
Greg Hewgill
2009-12-07 01:48:03