Re: VGA and dynamic placement of controls
- From: "<ctacke/>" <ctacke[at]opennetcf[dot]com>
- Date: Fri, 12 Oct 2007 18:18:01 -0500
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@xxxxxxxxx> wrote in message
news:1192209722.333597.299260@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.WorkingArea.Top;
int gScreenBottom =
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom;
int gScreenLeft =
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Left;
int gScreenRight =
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.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
.
- Follow-Ups:
- Re: VGA and dynamic placement of controls
- From: scottelloco@xxxxxxxxx
- Re: VGA and dynamic placement of controls
- References:
- VGA and dynamic placement of controls
- From: scottelloco@xxxxxxxxx
- VGA and dynamic placement of controls
- Prev by Date: Re: Out Of Memory Exception when using StringBuilder
- Next by Date: RE: Out Of Memory Exception when using StringBuilder
- Previous by thread: VGA and dynamic placement of controls
- Next by thread: Re: VGA and dynamic placement of controls
- Index(es):
Loading