With ProgressBar
and Gauge
you probably did not succeed because you would need to be updating the FrmProgress
.
Because with ProgressBar
and/or Gauge
? I don’t know what the behavior of an animated gif is like at Delphi. I already tried to put once, it was not native the use of animated gifs and then replace by other forms, usually ProgressBar
or Gauge
because I always need to give feedback on processing time.
To update the form I know three ways:
- Frmprogress.Update;
- Frmprogress.Refresh;
- Application.Processmessages.
The first two (Update and Refresh) you apply only on the form (Frmprogress) and only it processes display updates. Unfortunately I don’t know the difference between the two. But both make use of the Repaint method, which can also be called directly: FrmProgress.Repaint;
.
In the latter, the Application.ProcessMessages
you send an order to the entire system to process all information that has not yet been processed on the display.
For all options a more in-depth information, by source, would be interesting.
About your problem, I don’t know what is done in this method IsRunningProcess
and not because you use it in a while
, but actually it can be used to implement one of those methods I showed you and then remove the program print "locked".
Seria:
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 don’t know what you have in your job IsRunningProcess
, but I would venture to say that FrmProgress.Show;
and FrmPrincipal.Hide;
would not need to be inside the while
. I believe it’s unnecessary processing.
Try it like 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;
Should this form prevent access to other windows? Would it be like a splash screen? if an interesting example is put here later.
– Caputo