Re: Informative message during lengthy process

Posted by Glen on April 13, 2006

In Reply to Informative message during lengthy process posted by Timothy Mifsud on April 09, 2006

: I am running a lengthy process which reads words from files. I would like to show the user what is going on rather than leaving the application "hung". Typically, I would like to show an informative text with the word being processed. I cannot use a label and change its caption because it does not appear not even with refresh. I would greatly appreciate your help!

Insert the following line in the loop of your process:

Application.ProcessMessages;

That gives Windows time to handle other processes: show changes in visual components like labels, receive keypresses and mouse clicks, deal with other running applications, and so on...

Example:

N := 100000;   // or bigger number for fast computer
for i := 1 to N do begin
  Label1.Caption := IntToStr(i);
  Application.ProcessMessages;
end; 

Related Articles and Replies