Mostrar aviso em forma de hint no Delphi

Inclua na seção uses:Controls

 A rotina abaixo mostra a mensagem de aviso em forma
de "Hint", aguarda o tempo especificado e finalmente retira
a mensagem da tela.



procedure Aviso(const Msg: string; const Tempo: Cardinal);
var
  R: TRect;
  X: integer;
begin
  with THintWindow.Create(Application) do
  try
    { Calcula o retângulo }
    R := CalcHintRect(Screen.Width, Msg, nil);

    { Centraliza horizontalmente }
    X := R.Right - R.Left + 1;
    R.Left := (Screen.Width - X) div 2;
    R.Right := R.Left + X;

    { Centraliza verticalmente }
    X := R.Bottom - R.Top + 1;
    R.Top := (Screen.Height - X) div 2;
    R.Bottom := R.Top + X;

    { Mostra }
    ActivateHint(R, Msg);
    Update;

    { Aguarda }
    Sleep(Tempo);
  finally
    Free;
  end;
end;

Exemplo de uso:
Aviso('Mensagem de aviso', 5000); { Aguarda 5 segundos }