win32
asked on
SetTimer Priority
Hi
How do you set a priority for a timer, I want to make an IDLE timer, but is'nt there a function like
.SetPriority(LOW);
CB.
How do you set a priority for a timer, I want to make an IDLE timer, but is'nt there a function like
.SetPriority(LOW);
CB.
Hmmm... You can move it to the separate thread and set priority for it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SetTimer() is already a low-priority timer.
http://support.microsoft.com/support/kb/articles/Q96/0/06.ASP
http://msdn.microsoft.com/library/en-us/winui/hh/winui/messques_3ucn.asp?frame=true
http://support.microsoft.com/support/kb/articles/Q96/0/06.ASP
http://msdn.microsoft.com/library/en-us/winui/hh/winui/messques_3ucn.asp?frame=true
ASKER
But I am having some prublems, When my timer starts, my Redraw functions does'nt seem to work. eg. I click a button, but the button is not redrawn.
CB.
CB.
AFAIR WM_PAINT is a low-priority message too. Could you describe your problem in more detail?
ASKER
Only problem is sometimes a bit of flicker, because of the Paint() and Timer() running "at the same thread" at same time!
If a timer is running, can you reset it ?.. I mean, if i set the timer to 2 sec, and 1 second has elapsed, and for some reson I want to reset the timer, so it starts from the time 0 sec..
How can I do that ?, I mean I can't realy kill the timer it does'nt work, the timer will not be killed untill the next event.
Or can I kill the timer in a way, so I won't have to wait for the next event ?
If a timer is running, can you reset it ?.. I mean, if i set the timer to 2 sec, and 1 second has elapsed, and for some reson I want to reset the timer, so it starts from the time 0 sec..
How can I do that ?, I mean I can't realy kill the timer it does'nt work, the timer will not be killed untill the next event.
Or can I kill the timer in a way, so I won't have to wait for the next event ?
Of course you can kill the timer.
You can use this pair: KillTimer() SetTimer() even if you have no any timer at this time.
So, you can use something like this:
void ResetTimer(HWND hWnd, int id, int elapse) {
KillTimer(hWnd, id);
SetTimer(hWnd, id, elapse, NULL);
}
You can use this pair: KillTimer() SetTimer() even if you have no any timer at this time.
So, you can use something like this:
void ResetTimer(HWND hWnd, int id, int elapse) {
KillTimer(hWnd, id);
SetTimer(hWnd, id, elapse, NULL);
}
a) can you explain your problem? I'd like to doubt that two messages are handled at the same time in the same thread...
What windows does is: When Message Queue is empty, it sends WM_PAINT messages to windows with invalid regions. Only after that, pending WM_TIMER messages are sent.
Is all your painting in the WM_PAINT handler, or are you doing some of the painting in WM_TIMER? (you shouldn't....)
Peter
What windows does is: When Message Queue is empty, it sends WM_PAINT messages to windows with invalid regions. Only after that, pending WM_TIMER messages are sent.
Is all your painting in the WM_PAINT handler, or are you doing some of the painting in WM_TIMER? (you shouldn't....)
Peter
BTW... your WM_TIMER handler can also set a flag, that is processed & cleared in the Idle handler
VC++ frameworks (MFC, ATL) provide OnIdle handlers somewhere, or if you are in raw Win32, you might need to adjust your message loop for this.
Peter
VC++ frameworks (MFC, ATL) provide OnIdle handlers somewhere, or if you are in raw Win32, you might need to adjust your message loop for this.
Peter
ASKER
My painting is not in the Timer, but the timer makes some changes in some variables and call RePaint();
CB.
CB.
what is repaint?? You should just call InvalidateRect to invalidate theregions that need repainting.