Wednesday, December 19, 2007

Tip: How to programmatically check the orientation of your Windows Mobile device

In the past, I always compare the value of Me.Width and Me.Height (within a Form window) to determine the orientation mode of my Windows Mobile device. Besides this method, you can also use the ScreenOrientation property available in the SystemSettings class in the Microsoft.WindowsCE.Forms.dll, like this:

Dim o As Orientation = Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation
MsgBox(o.ToString)


For portrait mode, it returns Horizontal. For landscape mode, it returns Vertical.

No comments: