Capturing Win32 Mouse Repeat Events

Started by
3 comments, last by web383 11 years ago

Is it possible to receive WM_LBUTTONDOWN auto repeat events similar to WM_KEYDOWN with the standard repeat delay?

I'm working on a GUI, and would like to mimic scrollbars and repeat buttons much like the widgets in a C# WinForms application. I was hoping this would be possible without implementing a custom timer and handling it manually.

Advertisement

Can't you use WM_KEYDOWN directly with VK_LBUTTON and it's siblings?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

I did try that, and my mouse clicks don't seem to be triggering a WM_KEYDOWN message. Should they be? Or can VK_LBUTTON only be queried through GetKeyState() and GetAsyncKeyState()?

Windows will only send a single message when a mouse button is pressed and held, but it will send multiple (repeat) WM_KEYDOWN messages when a key on the keyboard is pressed and held. So yes, your scrollbar widget will have to use timers (or some other mechanism for performing an action with a certain frequency) to mimic the standard scrollbar behavior. But using Windows' timers is not difficult at all, so I don't see why you would want to avoid them.

Thanks for the replies. This is exactly the behavior I've encountered. Using a timer isn't an issue at all, I was mostly curious if it was possible otherwise.

I'm also using SystemParametersInfo() with SPI_GETKEYBOARDDELAY and SPI_GETKEYBOARDSPEED to query the initial delay and repeat speeds of the keyboard settings, and just applying it to a custom mouse-down repeat event.

This topic is closed to new replies.

Advertisement