-
Notifications
You must be signed in to change notification settings - Fork 1
/
UntSplash.pas
98 lines (82 loc) · 1.71 KB
/
UntSplash.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
unit UntSplash;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
System.Devices,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Graphics,
FMX.Dialogs,
FMX.Objects;
type
TfSplash = class(TForm)
Rectangle1: TRectangle;
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Image1Paint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
private
FInitialized : Boolean;
procedure LoadMainForm;
{ Private declarations }
public
{ Public declarations }
end;
var
fSplash: TfSplash;
implementation
uses
UntMain;
{$R *.fmx}
procedure TfSplash.FormCreate(Sender: TObject);
begin
Timer1.Enabled := False;
Timer1.Interval := 2000;
end;
procedure TfSplash.Image1Paint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
begin
Timer1.Enabled := not FInitialized;
end;
procedure TfSplash.LoadMainForm;
type
TFormClass = class of TForm;
var
Frm : TForm;
FrmClass : TFormClass;
begin
FrmClass := nil;
case TDeviceInfo.ThisDevice.DeviceClass of
TDeviceInfo.TDeviceClass.Desktop : FrmClass := TfMain;
TDeviceInfo.TDeviceClass.Phone : FrmClass := TfMain;
TDeviceInfo.TDeviceClass.Tablet : FrmClass := TfMain;
end;
if FrmClass <> nil then
begin
Frm := FrmClass.Create(Application);
Frm.Show;
Application.MainForm := Frm;
end
else
begin
ShowMessage('Formulário Inválido.');
end;
Close; //Fecha o form Splash
end;
procedure TfSplash.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not FInitialized then
begin
FInitialized := True;
LoadMainForm;
end;
end;
end.