unit fSplash;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, ORFn, VA508AccessibilityManager, VA508AccessibilityRouter, jpeg;

type
  TfrmSplashACM = class(TForm)
    pnlMain: TPanel;
    lblVersion: TStaticText;
    lblCopyright: TStaticText;
    pnlImage: TPanel;
    imgSplash: TImage;
    memDisclaimer: TMemo;
    lblSplash: TStaticText;
    amSplash: TVA508AccessibilityManager;
    pnl508Disclaimer: TPanel;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmSplashACM: TfrmSplashACM;
  procedure SplashOpen;
  procedure SplashClose;

implementation

{$R *.DFM}

uses VAUtils;

procedure TfrmSplashACM.FormCreate(Sender: TObject);
const
  Err508MSG = 'JAWS screen reader not %s.' + CRLF +
              'Running with limited 508 compliance.';
var
  ver: String;
begin
  ver := FileVersionValue(Application.ExeName, FILE_VER_FILEVERSION);
  lblVersion.Caption := 'version ' + ver;
  lblVersion.Invalidate;
  amSplash.AccessText[lblSplash] := amSplash.AccessText[lblSplash] + ' version ' + ver;

  if ScreenReaderActive then begin
    memDisclaimer.Lines.Insert(0, lblVersion.Caption);
    memDisclaimer.Lines.Insert(0, lblSplash.Caption);
  end;

  if ScreenReaderInstalled and (not ScreenReaderActive) then
    memDisclaimer.Lines.Insert(0, Format(Err508MSG, ['detected']));

  if ScreenReaderActive and (not ScreenReaderSystemActive) then
    memDisclaimer.Lines.Insert(0, Format(Err508MSG, ['initalized']));

  lblSplash.Invalidate;
end;

procedure SplashOpen;
begin
  frmSplashACM := nil;
  frmSplashACM := TfrmSplashACM.Create(Application);
  frmSplashACM.Show;
  frmSplashACM.Invalidate;
end;

procedure SplashClose;
begin
  if not Assigned(frmSplashACM) then EXIT;
  frmSplashACM.Release;
  frmSplashACM := nil;
end;

procedure TfrmSplashACM.FormShow(Sender: TObject);
begin
  lblSplash.SetFocus;
end;


initialization
  SpecifyFormIsNotADialog(TfrmSplashACM);

end.
