Delphi XE7で実行時にiOS・Androidアプリケーションの画面の向きを固定するには

Delphi XE7で実行時にiOS・Androidアプリケーションの画面の向きを固定するサンプルアプリケーションを作成します。

フォームにボタンを3つ配置します。

001

ボタンを押すと次のような処理を行います。

横固定…画面の向きを横に固定する
縦固定…画面の向きを縦に固定する
ユーザの現状態…画面の向きを固定しない

ソースコードは次のようになります。

procedure TForm1.ButtonLandscapeClick(Sender: TObject);
begin
  //横固定
  Application.FormFactor.Orientations :=
    [TFormOrientation.Landscape, TFormOrientation.InvertedLandscape];
end;

procedure TForm1.ButtonPortraitClick(Sender: TObject);
begin
  //縦固定
  Application.FormFactor.Orientations :=
    [TFormOrientation.Portrait, TFormOrientation.InvertedPortrait];
end;

procedure TForm1.ButtonUserClick(Sender: TObject);
begin
  //ユーザの現状態
  Application.FormFactor.Orientations :=
    [TFormOrientation.Landscape, TFormOrientation.InvertedLandscape,
     TFormOrientation.Portrait, TFormOrientation.InvertedPortrait];
end;

実行したところ

002

003

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください