Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog repainting

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have created a small program that carries out certain processing on a number of files. This processing takes a couple of minutes to complete. I had the bright idea of having the process output information to a listbox as it’s progressing. This I have been able to do without much difficulty. The end result is a listbox that contains usually around 2000 lines of text. So far so good.
My problem is, if during the processing I move to another application, and then attempt to come back to my program, I can’t. Or rather, I can come back to my program, but the dialog isn’t painted until it’s file processing completes. Is this due to the inherent design of Windows, or (much more likely) some failing in my code?
Any advice would be gratefully received.
Cheers.
 
Hi

All Windows application have a loop, hiddent inside the code, that process all the messages that it receives. Examples of message are mouse click, time ticks, window resize, menu selection, ...
Once a message is received by the application, it should be processed as fast as possible to allow the application to receive the other messages pending in the message queue.
If the processing of a message is very long, your application looks dead as it cannot receive and, hence, process any new messages.
You can Solve this in two ways:
* the hard one, make your application multi-thread. This is the best one as the processing does not interfer with the message queue processing
* the easy one: use a timer to perform small amount of processing. Let's say, read one file at each timer tick.
Between two timer messages, the application can process other messages as the one it receives when it's time to update the display of your list box.

HTH

Thierry
EMail: Thierry.Marneffe@swing.be

 
Thank you. I appreciate the reply, it gives me something to work on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top