VB.NET Sample Code - Rotate Screen / Screen Orientation

Post Reply
nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

VB.NET Sample Code - Rotate Screen / Screen Orientation

Post by nicolas » Tue Oct 20, 2009 12:46 am

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.

amirshah77
Posts: 17
Joined: Tue Oct 20, 2009 3:41 pm

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

Post by amirshah77 » Tue Dec 01, 2009 4:03 pm

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?

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

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

Post by nicolas » Tue Dec 01, 2009 4:42 pm

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

amirshah77
Posts: 17
Joined: Tue Oct 20, 2009 3:41 pm

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

Post by amirshah77 » Tue Dec 01, 2009 5:08 pm

that was quick...

thanks a lot!

Abuda
Posts: 7
Joined: Fri Dec 25, 2009 4:21 am

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

Post by Abuda » Thu Jan 14, 2010 4:29 am

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.

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

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

Post by nicolas » Thu Jan 14, 2010 9:03 am

Are you in a WindowsCE project ?

Abuda
Posts: 7
Joined: Fri Dec 25, 2009 4:21 am

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

Post by Abuda » Thu Jan 14, 2010 11:18 am

Yes, Visual Basic -> Smart Devices -> Windows CE 5.0 -> Device application

Abuda
Posts: 7
Joined: Fri Dec 25, 2009 4:21 am

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

Post by Abuda » Fri Jan 15, 2010 5:23 am

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.

Abuda
Posts: 7
Joined: Fri Dec 25, 2009 4:21 am

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

Post by Abuda » Fri Jan 15, 2010 8:24 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest