How to prevent automatic screen rotation on the tablet?

In the link below, Microsoft describes two ways to limit the screen rotation of an application on a tablet.

http://msdn.microsoft.com/en-ca/library/windows/apps/hh700342.aspx

what happens is that delphi (XE3) TRibbon does not cope with the rotation. he has a tendency to hang.

as expected, the MS website describes how to do this from MS development products. I do not see how I can do this in my Delphi project.

Method 1:

add this to your appxmanifest file:

<InitialRotationPreference>
    <Rotation Preference="landscape"/>
    <Rotation Preference="landscapeFlipped"/>
</InitialRotationPreference>

I have not yet found where / how appxmanifest should be part of the application, so I can do it in delphi.

Method 2:

call it code:

 Windows.Graphics.Display.DisplayProperties.AutoRotationPreferences =
            Windows.Graphics.Display.DisplayOrientations.Landscape;

in order to port this to delphi, I would need to know the info of the DLL API so that I could do something like this.

Any ideas?

COM- DLL, ?

+5
1

WindowsRT (FKA Metro), Delphi (). Metropolis - . Intel.

X-Ray :

unit MetroDisplayRotation;

(* 
 *  Usage: TMetroDisplayRotation.SetDisplayAutoRotationPreferences(
 *           TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE or 
 *           TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED);
 *)

interface

type
  TMetroDisplayRotation = class
  public const
    ORIENTATION_PREFERENCE_NONE = $0;
    ORIENTATION_PREFERENCE_LANDSCAPE = $1;
    ORIENTATION_PREFERENCE_PORTRAIT = $2;
    ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = $4;
    ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = $8;

    class procedure SetDisplayAutoRotationPreferences(ORIENTATION_PREFERENCE: Integer);
  end;

implementation

uses
  SysUtils, Windows;

{ TMetroDisplayRotation }

class procedure TMetroDisplayRotation.SetDisplayAutoRotationPreferences(
  ORIENTATION_PREFERENCE: Integer);
type
  TSDARP = procedure(ORIENTATION_PREFERENCE: Integer); stdcall;
var
  UserHandle: THandle;
  SDARP: TSDARP;
begin
  UserHandle := GetModuleHandle('User32.dll');
  @SDARP := GetProcAddress(UserHandle, 'SetDisplayAutoRotationPreferences');
  if Assigned(SDARP) then
    SDARP(ORIENTATION_PREFERENCE);
end;

end.

, Windows 8, .

: TMetroDisplayRotation.SetDisplayAutoRotationPreferences(TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE or TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED);

BAD - . HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AutoRotation Enable 0.

+6

All Articles