WM_TIMER salvage 
Author Message
 WM_TIMER salvage

Hello,there,

I created a SDI application with two views.

Inside one view, I created a Timer. After this Timer
created, I run a long-duration routine.

I want to show user the countdown seconds for
this routine. But it sounds WM_TIMER
message was removed from message queue
while process is busy because WM_TIMER has
the lowest priority in the queue.

Anyone has an idea to salvage WM_TIMER?

Thanks a lot.

Justin



Wed, 30 Jul 2003 01:41:11 GMT  
 WM_TIMER salvage

Quote:
>I created a SDI application with two views.

>Inside one view, I created a Timer. After this Timer
>created, I run a long-duration routine.

>I want to show user the countdown seconds for
>this routine. But it sounds WM_TIMER
>message was removed from message queue
>while process is busy because WM_TIMER has
>the lowest priority in the queue.

Justin,

I guess you're not processing any messages while your long duration
function runs - that would explain why you don't get any timer
messages. You could run the function in a worker thread in order to
keep your UI responsive and able to report on the progress of the
function.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Wed, 30 Jul 2003 04:56:58 GMT  
 WM_TIMER salvage
WM_TIMER messages are not reliable for such things.  They are generally used
to update things during idle time.  Windows will only place 1 WM_TIMER
message in the queue at a time.  Therefore, until you get it no more will be
posted.  Furthermore, it will only post the message when there are no other
messages in the queue.  You should probably use the multimedia timers or the
builtin timers for this.  Refer to KB Q96006 for more information.

Michael Taylor, MCP - 2/12/01
DCS Corp.

Quote:

> Hello,there,

> I created a SDI application with two views.

> Inside one view, I created a Timer. After this Timer
> created, I run a long-duration routine.

> I want to show user the countdown seconds for
> this routine. But it sounds WM_TIMER
> message was removed from message queue
> while process is busy because WM_TIMER has
> the lowest priority in the queue.

> Anyone has an idea to salvage WM_TIMER?

> Thanks a lot.

> Justin



Sat, 02 Aug 2003 00:21:26 GMT  
 WM_TIMER salvage
The "best" way to solve your problem, as David pointed out, is to use a
thread for the process. However, for a quick-and-dirty solution, you can
include the code below in your class and call DoEvents() from within the
process loop... This allows messages to be responded to inside the long
loop, but has some side effects. You'll notice, for instance, that if you
grab the window and move it around while the countdown is running, that the
countdown will stop until the window is released.

void CMyDlg::DoEvents()
{
 MSG message;

 while(PeekMessage(&message,GetSafeHwnd(), 0,32000,PM_REMOVE)) {
  DispatchMessage(&message);
 }

Quote:
}

--

-------------------------------------------
Cecil A. Galbraith
http://www.codesoup.com
Programmers Utilities/Tips
-------------------------------------------

Quote:

> Hello,there,

> I created a SDI application with two views.

> Inside one view, I created a Timer. After this Timer
> created, I run a long-duration routine.

> I want to show user the countdown seconds for
> this routine. But it sounds WM_TIMER
> message was removed from message queue
> while process is busy because WM_TIMER has
> the lowest priority in the queue.

> Anyone has an idea to salvage WM_TIMER?

> Thanks a lot.

> Justin



Thu, 07 Aug 2003 21:58:09 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. WM_TIMER Salvage

2. WM_TIMER with IWebBrowser2

3. ATL activex and WM_TIMER

4. How to handle WM_TIMER in Windowless control ?

5. Cant get WM_TIMER to ActiveX control

6. WM_TIMER/On_Timer in CDocument ??

7. WM_TIMER messages in an NT Service

8. ---WM_TIMER for ATL---

9. CPropertyPage & WM_TIMER

10. wm_timer and MessageBox()

11. WM_TIMER problem in a ActiveX composant

12. problem with WM_TIMER and Modal Dialog

 

 
Powered by phpBB® Forum Software