HighTechTalks DotNet Forums  

VGA and dynamic placement of controls

Dotnet Framework (Compact Framework) microsoft.public.dotnet.framework.compactframework


Discuss VGA and dynamic placement of controls in the Dotnet Framework (Compact Framework) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
scottelloco@gmail.com
 
Posts: n/a

Default VGA and dynamic placement of controls - 10-12-2007 , 01:22 PM






Hi,

I'm developing a CF application to run on VGA and QVGA devices with
both 240x320 and 240x240 screens. I have everything working fine on
both screen sizes in QVGA mode, but VGA is giving me some problems.
I'm trying to write as little code as possible to accommodate for all
of these variables. I'm using VS 2005, C#, CF 2.0 and the VS 2005 VGA
emulator for testing (unfortunately I don't have a real VGA device to
determine if this is an issue with the emulator.)

I have a form with one textbox and two buttons (code below.) I
calculate the size of the of the textbox based on the right and bottom
bounds of the WorkignArea of the screen. In VGA mode when AutoScale
mode is set to dpi and AutoScaleDimensions is (96F, 96F) the textbox
huge and flows way off of the screen. The buttons size are static and
are the correct relative size in this scenario.

When I during off AutoScale then my textbox fits on the screen, since
the sizing is dynamic based on the WorkingArea parameters, but the
buttons are a quarter of the size they should be (as I would expect)
since their size is static.

Code:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F,
96F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Dpi;

int gScreenTop =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Top;
int gScreenBottom =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Bottom;
int gScreenLeft =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Left;
int gScreenRight =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Right;

//
// btnSync
//
this.btnSync.Size = new System.Drawing.Size(93, 21);
this.btnSync.Location = new
System.Drawing.Point((gScreenRight / 2) + 13, gScreenBottom - 80);

//
// btnCancel
//
this.btnCancel.Size = new System.Drawing.Size(93, 21);
this.btnCancel.Location = new
System.Drawing.Point(((gScreenRight / 2) - (btnCancel.Size.Width)) +
11, gScreenBottom - 80);

//
// txtStatus
//
frmSync.txtStatus.Location = new System.Drawing.Point(10,
10);
frmSync.txtStatus.Size = new
System.Drawing.Size(gScreenRight - 20, gScreenBottom - 100);

When on a VGA device, gScreenBottom = 640 and gScreenRight = 480. I
center the buttons by dividing the ScreenWidth by 2 and then taking
into account the size of the buttons, I then add a little buffer space
between the buttons.

In QVGA this technique works fine, but in VGA it seems to think that
the right bound (640) is way off to the right of the actual visible
screen and that the bottom bound (480) is way off the bottom of the
visible screen, so my buttons end up somewhere way down in never-never
land.

The same thing for the textbox. It overflows way past the end of the
screen when AutoScale is on. However when Autoscale is off the textbox
fits correctly on the screen (except as I mentioned and as I would
expect the button are a 1/4 of the size they should be, since their
size is static.)

Another thing that seems weird is that when AutoScale is true, the
WorkingArea.Top = 52 (the height of the top menu bar), but when
AutoScale is false WorkingArea.Top = 26. Should it always be 26 since
AutoScale should adjust for VGA mode?

Any assistance or links to information would be greatly appreciated.
I've searched around a read a good deal about developing for VGA and
QVGA devices, but this has me stumped.

Thanks, -Scott


Reply With Quote
  #2  
Old   
 
Posts: n/a

Default Re: VGA and dynamic placement of controls - 10-12-2007 , 07:18 PM






The behavior you describe actually makes perfect sense to me. VGA is
640x480. When you try to autosize, it pixel-doubles a 320x240 screen to fit
it. With auto-scale, a 540x4802 and a 320x240 app should need zero
modifications (excepti it might look ugly due to the pixel doubling).

You might look at anchoring and docking instead - it gives a lot better
results for resolution changes.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com

<scottelloco (AT) gmail (DOT) com> wrote

Quote:
Hi,

I'm developing a CF application to run on VGA and QVGA devices with
both 240x320 and 240x240 screens. I have everything working fine on
both screen sizes in QVGA mode, but VGA is giving me some problems.
I'm trying to write as little code as possible to accommodate for all
of these variables. I'm using VS 2005, C#, CF 2.0 and the VS 2005 VGA
emulator for testing (unfortunately I don't have a real VGA device to
determine if this is an issue with the emulator.)

I have a form with one textbox and two buttons (code below.) I
calculate the size of the of the textbox based on the right and bottom
bounds of the WorkignArea of the screen. In VGA mode when AutoScale
mode is set to dpi and AutoScaleDimensions is (96F, 96F) the textbox
huge and flows way off of the screen. The buttons size are static and
are the correct relative size in this scenario.

When I during off AutoScale then my textbox fits on the screen, since
the sizing is dynamic based on the WorkingArea parameters, but the
buttons are a quarter of the size they should be (as I would expect)
since their size is static.

Code:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F,
96F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Dpi;

int gScreenTop =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Top;
int gScreenBottom =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Bottom;
int gScreenLeft =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Left;
int gScreenRight =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Right;

//
// btnSync
//
this.btnSync.Size = new System.Drawing.Size(93, 21);
this.btnSync.Location = new
System.Drawing.Point((gScreenRight / 2) + 13, gScreenBottom - 80);

//
// btnCancel
//
this.btnCancel.Size = new System.Drawing.Size(93, 21);
this.btnCancel.Location = new
System.Drawing.Point(((gScreenRight / 2) - (btnCancel.Size.Width)) +
11, gScreenBottom - 80);

//
// txtStatus
//
frmSync.txtStatus.Location = new System.Drawing.Point(10,
10);
frmSync.txtStatus.Size = new
System.Drawing.Size(gScreenRight - 20, gScreenBottom - 100);

When on a VGA device, gScreenBottom = 640 and gScreenRight = 480. I
center the buttons by dividing the ScreenWidth by 2 and then taking
into account the size of the buttons, I then add a little buffer space
between the buttons.

In QVGA this technique works fine, but in VGA it seems to think that
the right bound (640) is way off to the right of the actual visible
screen and that the bottom bound (480) is way off the bottom of the
visible screen, so my buttons end up somewhere way down in never-never
land.

The same thing for the textbox. It overflows way past the end of the
screen when AutoScale is on. However when Autoscale is off the textbox
fits correctly on the screen (except as I mentioned and as I would
expect the button are a 1/4 of the size they should be, since their
size is static.)

Another thing that seems weird is that when AutoScale is true, the
WorkingArea.Top = 52 (the height of the top menu bar), but when
AutoScale is false WorkingArea.Top = 26. Should it always be 26 since
AutoScale should adjust for VGA mode?

Any assistance or links to information would be greatly appreciated.
I've searched around a read a good deal about developing for VGA and
QVGA devices, but this has me stumped.

Thanks, -Scott




Reply With Quote
  #3  
Old   
scottelloco@gmail.com
 
Posts: n/a

Default Re: VGA and dynamic placement of controls - 10-15-2007 , 11:36 AM



On Oct 12, 6:18 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
Quote:
The behavior you describe actually makes perfect sense to me. VGA is
640x480. When you try to autosize, it pixel-doubles a 320x240 screen to fit
it. With auto-scale, a 540x4802 and a 320x240 app should need zero
modifications (excepti it might look ugly due to the pixel doubling).

You might look at anchoring and docking instead - it gives a lot better
results for resolution changes.

--

Chris Tacke, eMVP
Join the Embedded Developer Communityhttp://community.opennetcf.com

scottell... (AT) gmail (DOT) com> wrote in message

news:1192209722.333597.299260 (AT) y27g2000pre (DOT) googlegroups.com...

Hi,

I'm developing a CF application to run on VGA and QVGA devices with
both 240x320 and 240x240 screens. I have everything working fine on
both screen sizes in QVGA mode, but VGA is giving me some problems.
I'm trying to write as little code as possible to accommodate for all
of these variables. I'm using VS 2005, C#, CF 2.0 and the VS 2005 VGA
emulator for testing (unfortunately I don't have a real VGA device to
determine if this is an issue with the emulator.)

I have a form with one textbox and two buttons (code below.) I
calculate the size of the of the textbox based on the right and bottom
bounds of the WorkignArea of the screen. In VGA mode when AutoScale
mode is set to dpi and AutoScaleDimensions is (96F, 96F) the textbox
huge and flows way off of the screen. The buttons size are static and
are the correct relative size in this scenario.

When I during off AutoScale then my textbox fits on the screen, since
the sizing is dynamic based on the WorkingArea parameters, but the
buttons are a quarter of the size they should be (as I would expect)
since their size is static.

Code:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F,
96F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Dpi;

int gScreenTop =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Top;
int gScreenBottom =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Bottom;
int gScreenLeft =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Left;
int gScreenRight =
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Right;

//
// btnSync
//
this.btnSync.Size = new System.Drawing.Size(93, 21);
this.btnSync.Location = new
System.Drawing.Point((gScreenRight / 2) + 13, gScreenBottom - 80);

//
// btnCancel
//
this.btnCancel.Size = new System.Drawing.Size(93, 21);
this.btnCancel.Location = new
System.Drawing.Point(((gScreenRight / 2) - (btnCancel.Size.Width)) +
11, gScreenBottom - 80);

//
// txtStatus
//
frmSync.txtStatus.Location = new System.Drawing.Point(10,
10);
frmSync.txtStatus.Size = new
System.Drawing.Size(gScreenRight - 20, gScreenBottom - 100);

When on a VGA device, gScreenBottom = 640 and gScreenRight = 480. I
center the buttons by dividing the ScreenWidth by 2 and then taking
into account the size of the buttons, I then add a little buffer space
between the buttons.

In QVGA this technique works fine, but in VGA it seems to think that
the right bound (640) is way off to the right of the actual visible
screen and that the bottom bound (480) is way off the bottom of the
visible screen, so my buttons end up somewhere way down in never-never
land.

The same thing for the textbox. It overflows way past the end of the
screen when AutoScale is on. However when Autoscale is off the textbox
fits correctly on the screen (except as I mentioned and as I would
expect the button are a 1/4 of the size they should be, since their
size is static.)

Another thing that seems weird is that when AutoScale is true, the
WorkingArea.Top = 52 (the height of the top menu bar), but when
AutoScale is false WorkingArea.Top = 26. Should it always be 26 since
AutoScale should adjust for VGA mode?

Any assistance or links to information would be greatly appreciated.
I've searched around a read a good deal about developing for VGA and
QVGA devices, but this has me stumped.

Thanks, -Scott
Thanks for your reply ctacke. What you're saying makes sense, but I
think what is confusing em the most is why
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Right would
point to an area that is way outisde of the visible screen. Shouldn't
WorkingArea.Right be the x coordinate of the furthest point to the
right ont he visible screen?

Thanks, -Scott



Reply With Quote
  #4  
Old   
 
Posts: n/a

Default Re: VGA and dynamic placement of controls - 10-15-2007 , 11:47 AM




Quote:
Thanks for your reply ctacke. What you're saying makes sense, but I
think what is confusing em the most is why
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Right would
point to an area that is way outisde of the visible screen. Shouldn't
WorkingArea.Right be the x coordinate of the furthest point to the
right ont he visible screen?
Yes, and it is. On a VGA device in portrait mode, that's a value of 480.
However if you have a Form set to autoscale and you are on a VGA device,
it's going to pixel-double. That means 480 is going to become 960. Remember
the *Form* is auto-scale, not the Screen, so querying Screen properties is
not affected by any scaling.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com




Reply With Quote
  #5  
Old   
scottelloco@gmail.com
 
Posts: n/a

Default Re: VGA and dynamic placement of controls - 10-15-2007 , 12:41 PM



On Oct 15, 10:47 am, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
Quote:
Thanks for your reply ctacke. What you're saying makes sense, but I
think what is confusing em the most is why
System.Windows.Forms.Screen.PrimaryScreen.WorkingA rea.Right would
point to an area that is way outisde of the visible screen. Shouldn't
WorkingArea.Right be the x coordinate of the furthest point to the
right ont he visible screen?

Yes, and it is. On a VGA device in portrait mode, that's a value of 480.
However if you have a Form set to autoscale and you are on a VGA device,
it's going to pixel-double. That means 480 is going to become 960. Remember
the *Form* is auto-scale, not the Screen, so querying Screen properties is
not affected by any scaling.

--

Chris Tacke, eMVP
Join the Embedded Developer Communityhttp://community.opennetcf.com
Got it. Thanks very much!



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.