Holy cow, I wrote a book!
A customer was adding diagnostics to their application and
wanted to know if there was a way to detect that the application
was being slow in processing its input.
These sorts of delays manifest themselves to the end user as
a sluggish application which is slow to respond to input events.
They already had a watchdog timer that was reset every time
their GetMessage call returned a message,
so they could capture stack traces if their application stopped
processing messages for more than X milliseconds.
They wanted to extend this diagnostic information to input delays.
Fortunately, there's an easy way to tell.
The GetMessageTime will tell you
the time the message was added to the queue,
so by subtracting that time from the current
you can determine how long the input message
sat in the queue.
(Sent messages are not queued messages,
so calling GetMessageTime for a sent
message doesn't work.)
There's a catch, here, though.
Since mouse messages are generated on demand,
GetMessageTime for a
WM_MOUSEMOVE message is usually
(It could be older if you forced a mouse move message
to be generated but left it in the queue.)
To get the actual time the mouse moved,
you need to