Filtri Menu 0 0.00

Detect device orientation change Delphi Firemonkey

Detect device orientation change Delphi Firemonkey

To detect device orientation change, you can use the following example:

uses System.Messaging, FMX.Platform;

var FId: Integer;

// Subscribe to TOrientationChangedMessage
FId := TMessageManager.DefaultManager.SubscribeToMessage(TOrientationChangedMessage, DoOrientationChanged);

// Write orientation change handler:
procedure TMyForm.DoOrientationChanged(const Sender: TObject; const M: TMessage);
var s: IFMXScreenService;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, s) then begin
    case s.GetScreenOrientation of
      TScreenOrientation.Portrait: ;
      TScreenOrientation.Landscape: ;
      TScreenOrientation.InvertedPortrait: ;
      TScreenOrientation.InvertedLandscape: ;
    end;
  end;
end;

// Unsubscribe the TOrientationChangedMessage
TMessageManager.DefaultManager.Unsubscribe(TOrientationChangedMessage, FId);
Condividi:

Iscriviti alla newsletter

Iscriviti alla nostra newsletter per ricevere offerte di sconto anticipate, aggiornamenti e informazioni sui nuovi prodotti.
Top