PC Review


Reply
Thread Tools Rate Thread

Problems while Changing Screen Orientation

 
 
Saurabh
Guest
Posts: n/a
 
      29th Dec 2004
Hi,
Can anyone please tell me any other way(s) to change the screen orientation.
Currently, What I did is:

1) Develop the UI based on a particular screen orientation ( portrait -
240X320).
2) In the resize event of every page, I found the ratio of height for the
current clientrectangle height to 320 and similar ratio for width.
i.e heightratio = this.clientrectangle.height/288 ( and not 320 because 320
is overall width and 288 is the client rectangle width that is there in my
app.)
widthratio = this.clientrectangle.width /240

3) I multiplied the bounds of each control with the height and width ratio
as in :
label1.bounds = new size((int)Math.Round(WidthRatio * x),
(int)Math.Round(HeightRatio * y))

With this, the orientation is changing but there is a lot of overlap between
the controls because of approximate results. Also, this approach is generic
i.e. independent of any resolution and orientation. Is there any better way
out?

Secondly, When we resize any form, then all the forms which are cached also
get resized. This causes a lot of overhead. Can we stop that.

Please help

Saurabh


 
Reply With Quote
 
 
 
 
Gérard Materna
Guest
Posts: n/a
 
      29th Dec 2004
Hi,

Check this :
http://www.devx.com/wireless/Article/21590

The approach is to create 2 forms (one vertical 246x318 and one horizontal
326x246) and then copy the InitializeComponent() to two methods

a.. Private Sub LandscapeMode()
a.. Private Sub PortraitMode()

and then switch between the 2 orientations in the Resize event of the form :

Private Sub Form1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Resize
If (Screen.PrimaryScreen.Bounds.Width > _
Screen.PrimaryScreen.Bounds.Height) Then
' switch to landscape mode
LandscapeMode()
Else
' switch to portrait mode
PortraitMode()
End If
End Sub

The incovenience is that it is not independant of the resolution... Maybe
something between the 2 approaches : one form vertical, one horizontal and
then scale for the resolution?

Hope this helps,
Gérard.


"Saurabh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> Can anyone please tell me any other way(s) to change the screen

orientation.
> Currently, What I did is:
>
> 1) Develop the UI based on a particular screen orientation ( portrait -
> 240X320).
> 2) In the resize event of every page, I found the ratio of height for the
> current clientrectangle height to 320 and similar ratio for width.
> i.e heightratio = this.clientrectangle.height/288 ( and not 320 because

320
> is overall width and 288 is the client rectangle width that is there in my
> app.)
> widthratio = this.clientrectangle.width /240
>
> 3) I multiplied the bounds of each control with the height and width ratio
> as in :
> label1.bounds = new size((int)Math.Round(WidthRatio * x),
> (int)Math.Round(HeightRatio * y))
>
> With this, the orientation is changing but there is a lot of overlap

between
> the controls because of approximate results. Also, this approach is

generic
> i.e. independent of any resolution and orientation. Is there any better

way
> out?
>
> Secondly, When we resize any form, then all the forms which are cached

also
> get resized. This causes a lot of overhead. Can we stop that.
>
> Please help
>
> Saurabh
>
>



 
Reply With Quote
 
Saurabh
Guest
Posts: n/a
 
      29th Dec 2004
Thanks for your reply.
This approach would bound me to just 2 resolutions i.e.
for portrait - 240X320 and for landscape 320X240. because I will be
hardcoding the size and location of controls......
What if some other resolution comes in picture........
say 480 X 320 or so.............
How will I counter that situation.............


"Gérard Materna" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> Check this :
> http://www.devx.com/wireless/Article/21590
>
> The approach is to create 2 forms (one vertical 246x318 and one horizontal
> 326x246) and then copy the InitializeComponent() to two methods
>
> a.. Private Sub LandscapeMode()
> a.. Private Sub PortraitMode()
>
> and then switch between the 2 orientations in the Resize event of the form

:
>
> Private Sub Form1_Resize(ByVal sender As Object, _
> ByVal e As System.EventArgs) _
> Handles MyBase.Resize
> If (Screen.PrimaryScreen.Bounds.Width > _
> Screen.PrimaryScreen.Bounds.Height) Then
> ' switch to landscape mode
> LandscapeMode()
> Else
> ' switch to portrait mode
> PortraitMode()
> End If
> End Sub
>
> The incovenience is that it is not independant of the resolution... Maybe
> something between the 2 approaches : one form vertical, one horizontal

and
> then scale for the resolution?
>
> Hope this helps,
> Gérard.
>
>
> "Saurabh" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> > Can anyone please tell me any other way(s) to change the screen

> orientation.
> > Currently, What I did is:
> >
> > 1) Develop the UI based on a particular screen orientation ( portrait -
> > 240X320).
> > 2) In the resize event of every page, I found the ratio of height for

the
> > current clientrectangle height to 320 and similar ratio for width.
> > i.e heightratio = this.clientrectangle.height/288 ( and not 320 because

> 320
> > is overall width and 288 is the client rectangle width that is there in

my
> > app.)
> > widthratio = this.clientrectangle.width /240
> >
> > 3) I multiplied the bounds of each control with the height and width

ratio
> > as in :
> > label1.bounds = new size((int)Math.Round(WidthRatio * x),
> > (int)Math.Round(HeightRatio * y))
> >
> > With this, the orientation is changing but there is a lot of overlap

> between
> > the controls because of approximate results. Also, this approach is

> generic
> > i.e. independent of any resolution and orientation. Is there any better

> way
> > out?
> >
> > Secondly, When we resize any form, then all the forms which are cached

> also
> > get resized. This causes a lot of overhead. Can we stop that.
> >
> > Please help
> >
> > Saurabh
> >
> >

>
>



 
Reply With Quote
 
Robert Levy [MS]
Guest
Posts: n/a
 
      29th Dec 2004
What you really want is Docking/Anchoring support for controls like .NET has
for desktop apps. That feature is not in .NET CF v1 but it will be in v2.
Depending on your timeline, you may want to consider working with the beta
version of VS 2005 and CF v2.

If that's not an option, then you will have to implement your own algorithm
for sizing and positioning controls. I'd recommend an approach that mimics
docking/anchoring (maintain distance between the selected sides of a control
and its parent).

--
Robert Levy
Program Manager
Mobile Devices Product Group
http://blogs.msdn.com/windowsmobile

This posting is provided "AS IS" with no warranties, and confers no
rights.

Saurabh wrote:
> Thanks for your reply.
> This approach would bound me to just 2 resolutions i.e.
> for portrait - 240X320 and for landscape 320X240. because I will be
> hardcoding the size and location of controls......
> What if some other resolution comes in picture........
> say 480 X 320 or so.............
> How will I counter that situation.............
>
>
> "Gérard Materna" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi,
>>
>> Check this :
>> http://www.devx.com/wireless/Article/21590
>>
>> The approach is to create 2 forms (one vertical 246x318 and one
>> horizontal 326x246) and then copy the InitializeComponent() to two
>> methods
>>
>> a.. Private Sub LandscapeMode()
>> a.. Private Sub PortraitMode()
>>
>> and then switch between the 2 orientations in the Resize event of
>> the form
>>
>>
>> Private Sub Form1_Resize(ByVal sender As Object, _
>> ByVal e As System.EventArgs) _
>> Handles MyBase.Resize
>> If (Screen.PrimaryScreen.Bounds.Width > _
>> Screen.PrimaryScreen.Bounds.Height) Then
>> ' switch to landscape mode
>> LandscapeMode()
>> Else
>> ' switch to portrait mode
>> PortraitMode()
>> End If
>> End Sub
>>
>> The incovenience is that it is not independant of the resolution...
>> Maybe something between the 2 approaches : one form vertical, one
>> horizontal and then scale for the resolution?
>>
>> Hope this helps,
>> Gérard.
>>
>>
>> "Saurabh" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Hi,
>>> Can anyone please tell me any other way(s) to change the screen
>>> orientation. Currently, What I did is:
>>>
>>> 1) Develop the UI based on a particular screen orientation (
>>> portrait - 240X320).
>>> 2) In the resize event of every page, I found the ratio of height
>>> for the current clientrectangle height to 320 and similar ratio for
>>> width. i.e heightratio = this.clientrectangle.height/288 ( and not
>>> 320 because 320 is overall width and 288 is the client rectangle
>>> width that is there in my app.)
>>> widthratio = this.clientrectangle.width /240
>>>
>>> 3) I multiplied the bounds of each control with the height and
>>> width ratio as in :
>>> label1.bounds = new size((int)Math.Round(WidthRatio * x),
>>> (int)Math.Round(HeightRatio * y))
>>>
>>> With this, the orientation is changing but there is a lot of
>>> overlap between the controls because of approximate results. Also,
>>> this approach is generic i.e. independent of any resolution and
>>> orientation. Is there any better way out?
>>>
>>> Secondly, When we resize any form, then all the forms which are
>>> cached also get resized. This causes a lot of overhead. Can we stop
>>> that.
>>>
>>> Please help
>>>
>>> Saurabh



 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Orientation is changing Miskacee Microsoft Access Reports 3 27th Jan 2009 05:04 AM
Keys for screen orientation problems Matthew Windows XP General 3 25th Nov 2008 11:42 PM
Changing data orientation Neel Microsoft Excel Discussion 1 4th Jan 2008 04:38 AM
Changing fill orientation =?Utf-8?B?RmVycmluNDQ0?= Microsoft Excel Misc 4 26th Jan 2005 08:51 PM
Problems with changing screen resolution Cody Thimm Windows XP Video 4 14th Aug 2004 11:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 PM.