unit SplashForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Global, Vcl.Imaging.jpeg;

type
  TSplashWindow = class(TForm)

    BackgroundImage: TImage;
    lblVersion: TLabel;
    lblInfo: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormHide(Sender: TObject);
  private
    { Private declarations }
  public
    procedure SetInfo(info:string);
  end;

var
  SplashWindow: TSplashWindow;

implementation

{$R *.dfm}

const
  DURATION = 900;

procedure TSplashWindow.FormCreate(Sender: TObject);
begin
  lblVersion.Caption := APP_VERSION + APP_BUILD;
  // AV: for compatibility with different UI color styles:
  with lblVersion do Canvas.Font := Font;
  Left := (Screen.Width - Width) div 2;
  Top := (Screen.Height - Height) div 2;
end;

procedure TSplashWindow.FormHide(Sender: TObject);
begin
  repeat
    Application.ProcessMessages;
  until CloseQuery;
  AnimateWindow(Handle, DURATION, {AW_BLEND} AW_CENTER or AW_HIDE)
end;

procedure TSplashWindow.FormShow(Sender: TObject);
begin
  AnimateWindow(Handle, DURATION, {AW_BLEND} AW_CENTER);
end;

procedure TSplashWindow.SetInfo(info: string);
begin
  // AV: for compatibility with different UI color styles:
  lblInfo.Repaint;
  lblInfo.Canvas.TextOut(0, 0, info);
end;

end.
