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.
I show a hint for a quick message, sth. like this:
function ShowHintMsg(Form: TForm; Hint: string): THintWindow;
var
Rect: TRect;
begin
Result := THintWindow.Create(nil);
Result.Canvas.Font.Size := Form.Font.Size * 2;
Rect := Result.CalcHintRect(Form.Width, Hint, nil);
OffsetRect(Rect, Form.Left + (Form.Width - Rect.Right) div 2,
Form.Top + (Form.Height - Rect.Bottom) div 2);
Result.ActivateHint(Rect, Hint);
// due to a bug/design in THintWindow.ActivateHint, might not be
// necessary with some versions.
Result.Repaint;
end;
procedure HideHintMsg(HintWindow: THintWindow);
begin
try
HintWindow.ReleaseHandle;
finally
HintWindow.Free;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
HintWindow: THintWindow;
begin
HintWindow := ShowHintMsg(Self, 'Please Wait...');
try
Sleep(2000); // do processing.
finally
HideHintMsg(HintWindow);
end;
end;