Ich gehe davon aus du benutzt Delphi XE5
ganze einfach:
Im Main Form Create:
Delphi-Quellcode:
procedure TfrmMain.FormCreate(Sender: TObject);
var
AppEventSvc: IFMXApplicationEventService;
begin
//do not forget to add in uses FMX.Platform
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(AppEventSvc)) then
AppEventSvc.SetApplicationEventHandler(AppEvent);
end;
dann im form private Bereich
Delphi-Quellcode:
TfrmMain = class(TForm)
.....
private
{ Private declarations }
.....
function AppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
Implementierung:
Delphi-Quellcode:
function TfrmMain.AppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
begin
case AAppEvent of
aeFinishedLaunching:
begin
end;
aeBecameActive:
begin
///code z.b. hier
end;
aeWillBecomeInactive:
;
aeEnteredBackground:
begin
// StopThreads;
///code z.b. hier
end;
aeWillBecomeForeground:
begin
end;
aeWillTerminate:
;
aeLowMemory:
;
aeTimeChange:
;
aeOpenURL:
;
end;
end;
gruss Daniel Magin
DeveloperExpert.net