我在 Delphi 中有一個播放視頻的應用程式。當我打開另一個應用程式但螢屏空白時,我一直聽到視頻聲音。我怎樣才能檢測到螢屏已經變黑,或者切換到另一個應用程式?
uj5u.com熱心網友回復:
我找到了解決辦法。
uses FMX.Platform;
procedure TMyForm.FormCreate(Sender: TObject);
var
AppEventSvc:IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService,IInterface(AppEventSvc)) then
begin
AppEventSvc.SetApplicationEventHandler(AppEvent);
end;
end;
function TMyForm.AppEvent(AAppEvent:TApplicationEvent;AContext:TObject):Boolean;
begin
if AAppEvent=TApplicationEvent.WillTerminate then
begin
// Do soomething
end;
Result:=True;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/363513.html
