refreshing a form while it's busy

I'm trying to make my program window stay painted even if another screen is activated and displayed in front of it.  This program runs a bunch of external programs.  I also have a duration to show how long it's been running.  My problem is that while I'm waiting for the process to complete, I am trying to make the program refresh the screen so that if I move a window over it, I can still go back to the screen and see the program status.  I don't feel all that confident in my understanding of the difference between update, refresh, and repaint, or what it means for an object to be invalid.  I have tried a bunch of combinations, but none of them work.  Here's what I have for the loop that I use to wait for the running process to complete.  Thanks in advance for your assistance.

  sleep( 2000 );
  lblTime.Caption := FormatDateTime('nn:ss',Time - StartTime);
  Result := Resultado;
until (Result <> STILL_ACTIVE) or Application.Terminated;
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Application.ProcessMessages doesn't work? E.g. replace sleep(2000) with Application.ProcessMessages...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hello bnac, , you might use a different code to wait for your other process to finish

if FileExists(ProcessInfo.lpFile) and ShellExecuteEx(@ProcessInfo) then
  while WaitForSingleObject(ProcessInfo.hProcess, 100) <> WAIT_OBJECT_0 do
    lblTime.Caption := FormatDateTime('nn:ss',Time - StartTime);
    //  if you have Application.ProcessMessages you will NOT need the Refresh
  end else
bnacAuthor Commented:

I added Application.ProcessMessages, and dropped the sleep time to 250, and it's working exactly as I expected.  Taking out the sleep time caused the program to go from 0% CPU utilization to 90%.  Thanks for your amazingly quick response!

bnacAuthor Commented:
Slick, Thanks for your reply.  I'm going to keep the wait loop that I have though, because I've used it in a few apps, and it works well.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.