Page 1 of 1

VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Tue Oct 20, 2009 12:46 am
by nicolas
To change the orientation of the screen you can make use of SystemSettings.ScreenOrientation.
It has 4 possible values, 1 for each orientation. 90 degrees apart.

This is for CF .NET 2.0 but should work with newer versions as well.


Sample:

Code: Select all

If (Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation = 3) Then
            Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation = 0
Else
            Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation = Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation + 1
End If
Place the above in a button or other method. It will rotate the screen with each call.

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Tue Dec 01, 2009 4:03 pm
by amirshah77
hi nicolas...

do you happen to know how to make "landscape" the default orientation of mini2440's wince? (i.e. make wince starts directly in landscape)

deleting SYSGEN_QVGAP in PB does not seem to help... (i read somewhere that this setting simply makes available certain resources - dialog boxes, etc - in dimensions suitable for the portrait orientation, so deleting it will not change wince's orientation)

any idea?

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Tue Dec 01, 2009 4:42 pm
by nicolas
Landscape or portrait I think is up for debate, at first I was going to say "but it is already in landscape mode".
On the 3.5" screen, the orientation is technically landscape (but it displays in portrait). Thus with the bigger screens, the view is in landscape.

Anyways, the default orientation can be changed by changing the registry. Change/set it in the project.reg file.

Code: Select all

[HKEY_LOCAL_MACHINE\System\GDI\Rotation]
    "Angle"=dword:5A

Code: Select all

Value 	Description
0 	No rotation.
5A 	90 degrees rotated clockwise.
B4 	180 degrees rotated clockwise.
10E 	270 degrees rotated clockwise.
From http://msdn.microsoft.com/en-us/library/ms904178.aspx

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Tue Dec 01, 2009 5:08 pm
by amirshah77
that was quick...

thanks a lot!

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Thu Jan 14, 2010 4:29 am
by Abuda
Hi,

I try to use your sample code but is not working here.

I use System.Windows.Forms.ScreenOrientation and Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation.

I receive the message WindowsCE is not a member of Microsoft for your code.

In my code I receive ScreenOrientation is not a member of Forms.

How to solve this?

I'm using Visual Studio 2005.

I'm a beginner and will appreciate your help.

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Thu Jan 14, 2010 9:03 am
by nicolas
Are you in a WindowsCE project ?

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Thu Jan 14, 2010 11:18 am
by Abuda
Yes, Visual Basic -> Smart Devices -> Windows CE 5.0 -> Device application

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Fri Jan 15, 2010 5:23 am
by Abuda
Nicolas I insert Microsoft.WindowsCE.Forms.dll inside my object browser,but there is no SystemSettings.ScreenOrientation in this dll.

Do I have to insert something more, like Imports Microsoft.WindowsCE.Forms?

Thanks.

Re: VB.NET Sample Code - Rotate Screen / Screen Orientation

Posted: Fri Jan 15, 2010 8:24 am
by Abuda
Problem solved.

I was trying to use Microsoft.WindowsCE.forms.dll Version 1.

Now I'm using version 2 and worked.

Nicolas thanks for your sample code.