none
Left Landscape Mode vs Right Landscape Mode vs Upside Down

    Question

  • I need to be able to detect the screen orientation of a windows mobile device.  I can tell whether it is in landscape mode or portrait mode by getting the screen metrics.  I can detect when it changes between these modes be requerying the screen dimensions in response to WM_SETTINGSCHANGED.  What I can't do is detect whether the device is in left hand landscape mode vs right hand portrait mode or right-side-up vs upside down.

    Can any one provide insight on how I would programmatically distinguish between these modes?
    Joel Ivory Johnson
    Sunday, June 28, 2009 8:20 PM

Answers

  • Each time someone changes screen orientation (via OS or programmatically), OS writes it to this registry:

    [HKLM\System\GDI\Rotation]
    "Angle"=dword:00000000

    Possible values are: 0, 90 (landscape right-handed), 180 (upside down), 270 (landscape left-handed).
    If You'll find my answer satisfactory or helpful - mark it as answered! Thank You. PS. Votes also doesn't hurt :).
    • Proposed as answer by Mal Loth Sunday, June 28, 2009 9:11 PM
    • Marked as answer by Joel Ivory Johnson Sunday, June 28, 2009 9:18 PM
    Sunday, June 28, 2009 9:11 PM

All replies

  • Each time someone changes screen orientation (via OS or programmatically), OS writes it to this registry:

    [HKLM\System\GDI\Rotation]
    "Angle"=dword:00000000

    Possible values are: 0, 90 (landscape right-handed), 180 (upside down), 270 (landscape left-handed).
    If You'll find my answer satisfactory or helpful - mark it as answered! Thank You. PS. Votes also doesn't hurt :).
    • Proposed as answer by Mal Loth Sunday, June 28, 2009 9:11 PM
    • Marked as answer by Joel Ivory Johnson Sunday, June 28, 2009 9:18 PM
    Sunday, June 28, 2009 9:11 PM
  • Also if You'd like to do it more elegant way You can use ChangeDisplaySettingsEx .
    You just need to set DEVMODE structure to DM_DISPLAYORIENTATION and with this You'll probaly get the same.
    But it might be slower then getting it from the registry.



    If You'll find my answer satisfactory or helpful - mark it as answered! Thank You. PS. Votes also doesn't hurt :).
    • Proposed as answer by Mal Loth Sunday, June 28, 2009 9:33 PM
    Sunday, June 28, 2009 9:33 PM