-
January 7th, 2009, 04:22 PM
#1
Using SetTimer in OnMouseMove
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?
-
January 7th, 2009, 04:52 PM
#2
Re: Using SetTimer in OnMouseMove
It is because (from MSDN):
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.
Victor Nijegorodov
-
January 7th, 2009, 05:04 PM
#3
Re: Using SetTimer in OnMouseMove
Originally Posted by rioch
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:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
January 8th, 2009, 02:36 AM
#4
Re: Using SetTimer in OnMouseMove
Originally Posted by VictorN
It is because (from MSDN):
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.
Is there a way to look at the message queue?
-
January 9th, 2009, 04:03 PM
#5
Re: Using SetTimer in OnMouseMove
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|