I'm using SetTimer in some functions which are causing the OnTimer function to be called correctly. However, when I use SetTimer in OnMouseMove, the OnTimer function is never called. Is this because OnMouseMove fires so many times (because the mouse is moving) that the timer message never gets processed, or is it something else?
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.
I'm using SetTimer in some functions which are causing the OnTimer function to be called correctly. However, when I use SetTimer in OnMouseMove, the OnTimer function is never called. Is this because OnMouseMove fires so many times (because the mouse is moving) that the timer message never gets processed, or is it something else?
Define "never". If you leave your mouse alone, would you get that OnTimer() call?
If you set the same timer over and over every time the mouse moves (but before the timer fires) - you are effectively cancelling the previous call to SetTimer().
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
I didn't notice that, thanks. I suppose that is close to the assumption I had.
Originally Posted by VladimirF
Define "never". If you leave your mouse alone, would you get that OnTimer() call?
If you set the same timer over and over every time the mouse moves (but before the timer fires) - you are effectively cancelling the previous call to SetTimer().
Never as in never ever. Even if I leave the mouse alone, it still doesn't fire.
---
Perhaps you could suggest another option? I'm using the timer to show a custom tooltip, since the mfc tooltip framework is, in my opinion, very limited. I can get the tooltip to show and hide nicely, but once shown, it only disappears when the hide timer calls OnTimer. In the case when the mouse isn't moved, this is perfect, but if the user moves their mouse, I'd rather have the tooltip hide straight away. If I hide the window and set the state to hidden, it never shows.
Don't have a full picture about your implementation but you can try this:
Post or Send a WM_CLOSE (or your own custom) message to the tooltip window from within OnMouseMove(). You should have a mechanism to avoid unnecessary calls to Post/Send after the tooltip is gone.
SendMessage() doesn't return till the messge is processed by the destination window, PostMessage() posts the message and immediately returns.
Bookmarks