I just want a quick and dirty non-modal, non-closable screen that pops up and goes away to make 2 seconds seem more like... 1 second. Using 3-5 lines of code.
If your application is doing work and not processing any messages during this brief period, you can just do
procedure TForm3.Button1Click(Sender: TObject);
begin
Form4.Show;
try
Sleep(2000);
finally
Form4.Hide;
end;
end;
where Form4
is the "please wait" form (which is fsStayOnTop
), and Sleep(2000)
symbolizes the work done.
Now, the best way to do things is in the background (maybe in a separate thread), or at least you should ProcessMessages
once in a while in slow process. If you do the latter, the equivalent of Sleep(2000)
will still not return until the process is complete, but you need to write
procedure TForm4.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := false;
end;
in the "please wait" dialog so it cannot be closed (not even with Alt+F4).
If you are using threads or something else more sophisticated, I think that I'll need more details in order to provide an appropriate answer.