Lock into Landscape mode

N

nicowyow

Hi,

I'm building an application that should always run in landscape mode
using compact framework 2. I came up with this:
private void Form1_Resize(object sender, EventArgs e)
{
if (SystemSettings.ScreenOrientation != ScreenOrientation.Angle270);
SystemSettings.ScreenOrientation = ScreenOrientation.Angle270;
}

but that throws an exception, so I put it in an GotFocus event, which
seems out to work just fine, on the emulator. However, that event is
never fired on my PDA.

Anyone has a clue why setting ScreenOrientation results in an exception
when it is assigned a value during OnResize or why GotFocus isn't
called on my PDA? Or is there any other way to lock the value of
ScreenOrientation?

Thanks for any input...
Nico
 
N

nicowyow

Ok, the GotFocus is ran, but only on startup and when a messagebox is
closed.

I also want to add that my application runs full screen.
 
N

nicowyow

I want to block people from adjusting the screenmode while running the
application, setting it to landscape in the firstplace is no problem.
So OnLoad would be useless..

I want to Lock into landscape mode, so i need some event to fire if
someone wants to change my to portrait or I need to lock the variable
in some way...
 
P

Peter Foot [MVP]

I'm pretty sure you can't lock the mode, but you can catch when the
orientation is changed (Resize event of form) and change it immediately back
as required (.NETCF v2.0 has
Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation)

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

I want to block people from adjusting the screenmode while running the
application, setting it to landscape in the firstplace is no problem.
So OnLoad would be useless..

I want to Lock into landscape mode, so i need some event to fire if
someone wants to change my to portrait or I need to lock the variable
in some way...
 
N

nicowyow

Thanks for the input, but like I said, that throws an exception on my
PDA, so I'm sure it will throw in on more devices...

I created a workaround :
onfocus it flips the screen to landscape if it isn't already
onresize i show a message dialog with "application only supports
landscape mode". Then after the user closes the dialog, the onfocus is
called and the application returns to landscape mode.

I don't like "solutions" like this, any descent solution would be nice.
 
G

Guest

The problem is that you are trying to override hardware behavior from your
application - something the device was not designed to support. This is why
you're supposed to make your UI dynamic.You're attempting to do something
that will affect all apps on the system, and that's generally not a good
practice, so there are no hooks provided to do it. Anything that might do
it will be a hack, and the only real way I can think of to do it well is to
write a new display driver so you can override the rotate requests.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--




Thanks for the input, but like I said, that throws an exception on my
PDA, so I'm sure it will throw in on more devices...

I created a workaround :
onfocus it flips the screen to landscape if it isn't already
onresize i show a message dialog with "application only supports
landscape mode". Then after the user closes the dialog, the onfocus is
called and the application returns to landscape mode.

I don't like "solutions" like this, any descent solution would be nice.
 
K

keeper

The other thing I'd be careful of is some devices have slide-out
keyboards.
If the keyboard slides out portrait then the user wouldn't be able to
use it with the app.
If the keyboard slides out landscape then there is the chance it may
slide out the opposite side to the orientation of your app.

Plus, what if the device doesn't support landscape (ie, a square
screen).
Working with a fixed layout like this may just cause you headaches in
the future when someone turns around and demands support for a
different pda.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top