Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse coordinates

Status
Not open for further replies.

gford2

Technical User
Oct 11, 2000
7
US
I need to know how i can list the mouse coordinates as the mouse moves. I guess i need a to know ho to break the program and read out the x-y coordinates.
After I find out how to get these coordinates, i'll send the x's to 0 and now i'll jsut have the y's.
Next and probably most importantly, how can i get the time between each reading so i can find the velocity of the mouse. You know, dy/dt. This isn't just something i'm playing around with but actually is going towards the design of something.
A quick response would be great.

Thanx for your time
GF

[sig][/sig]
 
in console programs check the interrutpion int 33h.
In windows programs you need do like this:
POINT pt;
GetCursorPos(&pt );
[sig][/sig]
 
Hi,

The WM_MOUSEMOVE message gives the x and y pos of the mouse in the lParam.

Dick


 
Hei Pappy
To check lParam of message WM_MOUSEMOVE is easy, but there can appear a lot of problems. There are a lot of messages,
WM_NCHITTEST, WM_LBUTTONDOWN, WM_LBUTONUP, WM_DBCLCK..... what are received by WndProc. At the first time you must detect the MouseMove, at the second time you must check, do you need at this time the coordinates, if you need it, you must comunicate them to the function what use them by a global variable or a lotof problems, but GetCursorPos you can use without problems everywhere.
 
Hi John,
I know that WM_MOUSEMOVE gives more hits than any sane person would want, but
if a person is programming, he/she may find a use for them.

Pappy
 
The message WM_MOUSEMOVE is received in any cases, if you need or no this information. But the function GetCursorPos you may use only if you need and when you need. Is better to use this function if you want know only mouse coordinates, and no more. If you need to know when the mouse is moving, is better to use WM_MOUSEMOVE, or other messages.
 
Hello,
WM_MOUSEMOVE and GetCursorPos( .. ), may be good for 2 parts of your post, but I'd like to help with third ( mouse velocity and so on )
Try with SystemParametersInfo( .. ) with SPI_GETMOUSE like first parameter, so this may be a good start point. Find more info about it in MSDN.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top