【源码结构】fmx横竖屏切换
unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls ; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} uses FMX.Platform; procedure TForm1.Button1Click(Sender: TObject); var AppService: IFMXScreenService; AOrientations: TScreenOrientations ; ScreenOrientation:TScreenOrientation; begin if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, AppService) then ScreenOrientation:=TScreenOrientation.Portrait; AOrientations:= [ScreenOrientation]; AppService.SetScreenOrientation(AOrientations); end; procedure TForm1.Button2Click(Sender: TObject); var AppService: IFMXScreenService; AOrientations: TScreenOrientations ; ScreenOrientation:TScreenOrientation; begin if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, AppService) then ScreenOrientation:=TScreenOrientation.Landscape; AOrientations:= [ScreenOrientation]; AppService.SetScreenOrientation(AOrientations); end; procedure TForm1.Button3Click(Sender: TObject); var AppService: IFMXScreenService; AOrientations: TScreenOrientations ; ScreenOrientation:TScreenOrientation; begin if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, AppService) then ScreenOrientation:=TScreenOrientation.InvertedPortrait; AOrientations:= [ScreenOrientation]; AppService.SetScreenOrientation(AOrientations); end; procedure TForm1.Button4Click(Sender: TObject); var AppService: IFMXScreenService; AOrientations: TScreenOrientations ; ScreenOrientation:TScreenOrientation; begin if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, AppService) then ScreenOrientation:=TScreenOrientation.InvertedLandscape; AOrientations:= [ScreenOrientation]; AppService.SetScreenOrientation(AOrientations); end; end.
评论