Screen orientation

As you probably know, Windows Mobile 5.0 has built in support for dynamically changing the screen orientation (e.g. portrait and landscape). For instance if you open the keyboard on the i-mate K-Jam (or the Qtec model) the screen automatically changes to landscape.

To accomodate this in a program (i.e. perform layout-changes to better suit the orientation) you can check the Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation property. Angle0 is portrait, and Angle270 is landscape. The best place is in the Form_Resize event. 

Example:

private void Form1_Resize(object sender, EventArgs e)
{
   if (Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation == Microsoft.WindowsCE.Forms.ScreenOrientation.Angle0)   
//Portrait:
{ TextBox1.Width = 240; }
else //Landscape:
{  TextBox1.Width = 320; }

}

Tip: To flip the Emulator in Visual Studio, you must first select the Form you are editing (use the Document Outline view if it is covered). Then right click the Form or the Emulator skin and select Rotate Left in the menu.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: