SetTimer ?
-
I have a dialog with a button and a progressbar. When the user clicks the button a lengthy process is initiated. During this process I want to increment the progressbar on a regular interval. I did this by setting a timer when the button is clicked, but the OnTimer function is never called. However it is called when I set the timer in the OnInitDialog function. It seems that the lengthy process that is initiated in the 'OnMyButtonClicked' function blocks the timer. Anyone knows a sollution for this problem?
-
I have a dialog with a button and a progressbar. When the user clicks the button a lengthy process is initiated. During this process I want to increment the progressbar on a regular interval. I did this by setting a timer when the button is clicked, but the OnTimer function is never called. However it is called when I set the timer in the OnInitDialog function. It seems that the lengthy process that is initiated in the 'OnMyButtonClicked' function blocks the timer. Anyone knows a sollution for this problem?
you need to have event pumped into your lenghty process. I thing there are samples here on code project, have a look around.
Maximilien Lincourt "Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
-
I have a dialog with a button and a progressbar. When the user clicks the button a lengthy process is initiated. During this process I want to increment the progressbar on a regular interval. I did this by setting a timer when the button is clicked, but the OnTimer function is never called. However it is called when I set the timer in the OnInitDialog function. It seems that the lengthy process that is initiated in the 'OnMyButtonClicked' function blocks the timer. Anyone knows a sollution for this problem?
Brian van der Beek wrote: When the user clicks the button a lengthy process is initiated. Do this lengthy progress in a worker thread. Have this worker thread send PostMessages to its parent(View), which in turn sets the Progress bar. For threads, I recommend this article.[^] [edit] You can also use a message pump as suggested (code is in the Prosise-book), but that tends to get complicated.
Who is 'General Failure'? And why is he reading my harddisk?!?
-
Brian van der Beek wrote: When the user clicks the button a lengthy process is initiated. Do this lengthy progress in a worker thread. Have this worker thread send PostMessages to its parent(View), which in turn sets the Progress bar. For threads, I recommend this article.[^] [edit] You can also use a message pump as suggested (code is in the Prosise-book), but that tends to get complicated.
Who is 'General Failure'? And why is he reading my harddisk?!?
I now use a worker thread and everything works fine. Thanks for your reply.
-
I have a dialog with a button and a progressbar. When the user clicks the button a lengthy process is initiated. During this process I want to increment the progressbar on a regular interval. I did this by setting a timer when the button is clicked, but the OnTimer function is never called. However it is called when I set the timer in the OnInitDialog function. It seems that the lengthy process that is initiated in the 'OnMyButtonClicked' function blocks the timer. Anyone knows a sollution for this problem?
In Win32 you should use a worker thread to handle lengthy processes in the background so that normal message passing can continue. If you do not want to use a worker thread then you will need to to use one of the old tricks used before mult-threading. 1) Use some thing like this if( PeekMessage(...) ) // in lengthy process loop { DispatchMessage(...) } to allow other messages to be processed. OR 2) Use a user defined message that you keeping posting to your self until the job is fininish. There by allowing other messages to flow. This works as follows: PostMessage(MY_MESSAGE); // Get processing started ... Proc(MY_MESSAGE) { swicth(message) { case MY_MESSAGE: // do part of processing if( !done ) PostMessage(MY_MESSAGE); break. } Both of the above method will increase the amount of time it take to do the lengthy process, but they both work to solve your problem. I hope this give you some ideas as to how to solve your problem. INTP
-
I now use a worker thread and everything works fine. Thanks for your reply.
Brian van der Beek wrote: I now use a worker thread You did this within 20 minutes? :omg: Wow - you code pretty fast! :)
Who is 'General Failure'? And why is he reading my harddisk?!?