With ProgressBar
and Gauge
you probably did not succeed because you would need to be updating FrmProgress
.
Because with ProgressBar
and / or Gauge
? I do not know what the behavior of an animated gif in Delphi is. I have tried to put it once, it was not native to using animated gifs and then replaced with other shapes, usually ProgressBar
or Gauge
because I always need to give feedback on the processing time.
To update the form I know three ways:
FrmProgress.Update;
FrmProgress.Refresh;
Application.ProcessMessages.
The first two ( Update and Refresh ) apply only to the form ( FrmProgress ) and only it handles the display updates. Unfortunately I do not know the difference between the two. But both make use of the Repaint method, which can also be called directly: FrmProgress.Repaint;
.
In the last one, Application.ProcessMessages
sends an order to the whole system to process all information that has not yet been processed in the display.
For all options a more in-depth information, by source, would be interesting.
On your issue, I do not know what's done with this IsRunningProcess
method, nor why you use it in while
, but actually it can be used to implement one of these methods I showed you and then remove the "locked" program impression.
It would be:
while IsRunningProcess('nome_do_processo') do
begin
FrmProgress.Show;
FrmPrincipal.Hide;
FrmProcess.Refresh;
// ou FrmProgress.Update;
// ou Application.ProcessMessages; // esse, em threads, costuma dar problemas
end;
FrmProgress.Close;
Application.MessageBox('Operação concluída com sucesso!', 'Ferramentas',
MB_ICONEXCLAMATION + MB_OK);
FrmPrincipal.Visible := True;
A suggestion for testing
I do not know what to do with your IsRunningProcess
function, but I'd venture to say that FrmProgress.Show;
and FrmPrincipal.Hide;
need not be within while
. I believe it's unnecessary processing.
Try this:
FrmProgress.Show;
FrmPrincipal.Hide;
while IsRunningProcess('nome_do_processo') do
begin
FrmProgress.Refresh;
// ou FrmProgress.Update;
// ou Application.ProcessMessages; // esse, em threads, costuma dar problemas
end;
FrmProgress.Close;
Application.MessageBox('Operação concluída com sucesso!', 'Ferramentas',
MB_ICONEXCLAMATION + MB_OK);
FrmPrincipal.Visible := True;