Thursday, January 3, 2008

Determine your current Screen Orientation on a Windows Mobile Device

There are many facets of "orientation-aware" apps. There are 2 portrait and 2 landscape modes making 4 possible orientations (0, 90, 180, 270).

I have an application that lets the user set custom keys in an application. At first, I thought I only need to store a landscape set and a portrait set; however, depending on the user, the landscape mode might be in the 90 degree position or the 270 degree position. The keys selected by the user may be very different depending on which one of these orientations gets used.

However, it is very simple to find out what the current screen orientation in on the device:

Imports Microsoft.WindowsCE.Forms
.
.
.
Select Case SystemSettings.ScreenOrientation

Case ScreenOrientation.Angle0
.

.
.
Case ScreenOrientation.Angle90
.

.
.
Case ScreenOrientation.Angle180
.

.
.
Case ScreenOrientation.Angle270
.

.
.
End Select


More Info at:
http://msdn2.microsoft.com/en-us/library/microsoft.windowsce.forms.systemsettings.screenorientation(VS.80).aspx

No comments: