PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Portrait only?

Reply

Portrait only?

 
Thread Tools Rate Thread
Old 08-09-2006, 03:20 PM   #1
=?Utf-8?B?Tm9ibGUgQmVsbA==?=
Guest
 
Posts: n/a
Default Portrait only?


Is there a way to make one's application *ONLY* work in portrait mode without
to much effort?


------------------------------------------
Noble D. Bell
AgForest Partners, Inc.

  Reply With Quote
Old 08-09-2006, 04:26 PM   #2
Guest
 
Posts: n/a
Default Re: Portrait only?

Whaqt do you mean? Have the app not load if the device is landscape or
something like that? You could always check the screen dimensions at
startup (Screen.PrimaryScreen.Width & Height) and toss up a message at that
point.


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


"Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
news:EF841BAB-EED1-4ACE-AC81-B3183FD80E6B@microsoft.com...
> Is there a way to make one's application *ONLY* work in portrait mode
> without
> to much effort?
>
>
> ------------------------------------------
> Noble D. Bell
> AgForest Partners, Inc.
>



  Reply With Quote
Old 08-09-2006, 04:39 PM   #3
=?Utf-8?B?Tm9ibGUgQmVsbA==?=
Guest
 
Posts: n/a
Default Re: Portrait only?

That is what I mean. This is what I have come up with.

I place the following code in the form's Got_Focus event:

Dim screenHeight As Integer = Me.Bottom + Me.Top
Dim screenWidth As Integer = Me.Left + Me.Right
Dim txt As String = ""
Dim x As Integer

If screenHeight = 240 & screenWidth = 320 Then
' landscape mode
txt = "This program is designed to " + vbCrLf
txt = txt + "work in portrait mode only." + vbCrLf + vbCrLf
txt = txt + "Please reset to portrait mode and try again."

x = MessageBox.Show(txt, "Orientation Error!",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1)
Application.Exit()
ElseIf screenHeight = 320 & screenWidth = 240 Then
' portrait mode
End If


It appears to be working so far.


------------------------------------------
Noble D. Bell
AgForest Partners, Inc.



"<ctacke/>" wrote:

> Whaqt do you mean? Have the app not load if the device is landscape or
> something like that? You could always check the screen dimensions at
> startup (Screen.PrimaryScreen.Width & Height) and toss up a message at that
> point.
>
>
> --
> Chris Tacke
> OpenNETCF Consulting
> Managed Code in the Embedded World
> www.opennetcf.com
> --
>
>
> "Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
> news:EF841BAB-EED1-4ACE-AC81-B3183FD80E6B@microsoft.com...
> > Is there a way to make one's application *ONLY* work in portrait mode
> > without
> > to much effort?
> >
> >
> > ------------------------------------------
> > Noble D. Bell
> > AgForest Partners, Inc.
> >

>
>
>

  Reply With Quote
Old 08-09-2006, 07:05 PM   #4
Peter Foot [MVP]
Guest
 
Posts: n/a
Default Re: Portrait only?

You can access the System.Windows.Forms.Screen.PrimaryScreen.Bounds rather
than working out the size from your form. Also rather than quitting and
giving the user instructions to change the orientation you can change it
yourself in code. If you are using .NETCF v2.0 use the
Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation property, for
v1.0 there is a matching class in the Mobile In The Hand Community Edition:-
http://www.inthehand.com/WindowsMobile.aspx

Peter

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

"Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
news:CCD0DDE1-7DEC-4E5C-BFA7-AE539E5AB68E@microsoft.com...
> That is what I mean. This is what I have come up with.
>
> I place the following code in the form's Got_Focus event:
>
> Dim screenHeight As Integer = Me.Bottom + Me.Top
> Dim screenWidth As Integer = Me.Left + Me.Right
> Dim txt As String = ""
> Dim x As Integer
>
> If screenHeight = 240 & screenWidth = 320 Then
> ' landscape mode
> txt = "This program is designed to " + vbCrLf
> txt = txt + "work in portrait mode only." + vbCrLf + vbCrLf
> txt = txt + "Please reset to portrait mode and try again."
>
> x = MessageBox.Show(txt, "Orientation Error!",
> MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
> MessageBoxDefaultButton.Button1)
> Application.Exit()
> ElseIf screenHeight = 320 & screenWidth = 240 Then
> ' portrait mode
> End If
>
>
> It appears to be working so far.
>
>
> ------------------------------------------
> Noble D. Bell
> AgForest Partners, Inc.
>
>
>
> "<ctacke/>" wrote:
>
>> Whaqt do you mean? Have the app not load if the device is landscape or
>> something like that? You could always check the screen dimensions at
>> startup (Screen.PrimaryScreen.Width & Height) and toss up a message at
>> that
>> point.
>>
>>
>> --
>> Chris Tacke
>> OpenNETCF Consulting
>> Managed Code in the Embedded World
>> www.opennetcf.com
>> --
>>
>>
>> "Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
>> news:EF841BAB-EED1-4ACE-AC81-B3183FD80E6B@microsoft.com...
>> > Is there a way to make one's application *ONLY* work in portrait mode
>> > without
>> > to much effort?
>> >
>> >
>> > ------------------------------------------
>> > Noble D. Bell
>> > AgForest Partners, Inc.
>> >

>>
>>
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off