AutoScale not working

M

Michael Coelsch

When i create a Form in VS 2005 (VB.NET), the designer shows all controls
(Picture Boxes, ...) correctly in a form (240x320 pixel).
But when i deploy to a VGA device or the VGA emulator, all controls to not
autoscaled and appear very small in the top left quarter corner of the
screen.

What can i do?

Autoscale mode of the form is set to DPI.

I have an english VS.NET 2005 on a german Win XP machine.

Thanks
Michael
 
P

Paker Liu

Michael said:
When i create a Form in VS 2005 (VB.NET), the designer shows all controls
(Picture Boxes, ...) correctly in a form (240x320 pixel).
But when i deploy to a VGA device or the VGA emulator, all controls to not
autoscaled and appear very small in the top left quarter corner of the
screen.

What can i do?

Autoscale mode of the form is set to DPI.

I have an english VS.NET 2005 on a german Win XP machine.

Thanks
Michael
if Autoscaled mode is not work,I suggest that you write some code to
recognize wether it is VGA device before all controls initialize.Usually
My app does not choose AutoScaled mode.It is the same reason that
Autoscaled mode is not well work!
 
M

Michael Coelsch

Hi,

i thought VS 2005 would take care about resizing controls (especially
picture boxes) automatically for VGA and QVGA support??

What can i do?

The controls location is OK, but the picture in the picture-box is not
autoscaled to QVGA resolution!

Michael
 
P

Paul G. Tobey [eMVP]

It has some layout capabilities to *assist* with that, but there's no
general method of just making things work that would make sense for all
applications.

Paul T.
 
P

Paul Moon

Is there any way to make it work the same way it did in VS 2003? I have
an app I have been developing using a VGA device, and it always just
scaled everything for me under CF 1.0. Now I have upgraded the project
to CF 2.0 and I cannot get it to behave the same way!
 
E

eastlands

I have also found this very frustrating. I have found that in addition
to setting AutoScaleMode=dpi you need to set AutoScaleBaseSize.

If you create a new form/control in VS 2005 it seems to set these
properties by default, however I have had to add them when migrating
from a VS2003 project.

Having done this most controls appear ok, however images (including
those on listviews and toolbars) do not get scaled. I do not know any
way to get this done automatically so I think I will have to write
additional code to test the screen resolution and scale the images
myself. Does anyone have a better idea?

This is frustrating as I like all the other benefits that VS2005
brings.

Stuart Eastland
 
S

Simon Hart

VS2005 does not scale icons in imagelists as used for ListView controls and
Toolbar controls. Unfortunately you have to code for it, then test on VGA
and QVGA devices/emulators.

At first this seems like a pain but when you think about it it is quite
resonable as you might want to use 48x48 under LargeIcon view in a listview
not whatever the factor for the form might be. In VGA devices (192 dpi) this
will be 32*192/96 = 64.

Cheers
Simon.
 
S

Simon Hart

VS2003 didn't handle scaling icons. VS2005 works the same as VS2003. You
still have to specify the size of the imagelist in both 2003 and 2005.

It would have been nice for VS2005 to automatically change the size of the
toolbar imagelist as when running in hidpi you want to use 32x32 not 16x16.

Cheers
Simon.
 
G

Graham McKechnie

Simon,

Reasonable - but still a bloody pain to have to do all this, when VS2003
handled it all automatically.

Every dynamically added control requires scaling and then testing on both
devices. That's a fair amount of testing, just to convert an app to VS2005 -
eh?

There are plenty of other "gottchas" too. Well it least it gives you a
chance to review your code and that can't be all bad.

Graham
 
G

Graham McKechnie

Simon,

I must have got away with something then in 2003. My icons look just right
when I deploy the 2003 app to either device.

Graham
 
S

Simon Hart

This is because 2003 double buffers the screen when deploying a non-dpi
aware app on a hires device.

Cheers
Simon.
 
G

Graham McKechnie

Hi Simon,

Could you explain that further? The 2003 technique sounds like a simpler
solution, so there must have been a good reason for going away from it in
2005. Is it quicker the new way?

I keep revising the way I'm doing this and I keep finding new ways to do the
same thing. But I would like to make it as efficient as possible.

For my custom controls I'm swinging to handling the scaling with
ScaleControl in OnParentChanged, but then you need to check who the Parent
is. But that doesn't get around using g.DpiX and g.DpiY in OnPaint if you
happen to adjust anything in there.

Re ImageLists I now find that I need both 16x16 and 32x32. Is there a tool
around that easily converts gif, icons, bmp etc. from one size to another.
I've been redrawing them, which I'm not to flash at and it's taking for
ever.

Graham
 
S

Simon Hart

Hi Graham,

The 2003 solution was simple but under developed and didn't support hires
devices such as the iPAQ h4700 which is 640x480 dpi or the iMate JasJar
etc..There are still lots of new devices being manufactured that only
contain QVGA screens 240x320. So with VS2005 Microsoft has added support for
both types. This makes sense as you can take advantage of the nice higher
resolution making your icons, text etc look nice and crisp.

If you want to go back to double buffering (as per VS2003) then you can set
the AutoScaleMode of class Form to None.

There was also a nasty little bug in VS2003 re imagelists. It wouldn't
support transparent backgrounds when adding Icons via the designer. So this
had to be done via code. So it wasn't so much hardship for me to support
hires as all I had to do was add additional code to change the size of the
imagelist depending on the resolution, then create a bigger icon from the
exiting icon stream.

Supporting DPI awareness in your Controls: Why don't you just handle the GDI
drawing in the OnPaint event then change each hard coded coordinate to
something like:

value * g.DpiY / 96.

I personally always use Icons and use the Michelangelo icon editor - do a
google I'm sure you'll find the site I can't remember it now.

Cheers
Simon.
 
G

Graham McKechnie

Simon,

Thanks for your reply. You originally mentioned that VS2003 double buffers
the screen - that was the bit I didn't understand. Could you expand on that?

I didn't know that AutoScaleMode.None gave you the default VS2003 behaviour.
A bit late now as I'm nearly done converting this app, but I'll keep that in
mind for some other apps that I want to convert that will never run on high
resolution devices.
Supporting DPI awareness in your Controls: Why don't you just handle the
GDI drawing in the OnPaint event then change each hard coded coordinate to
something like:

value * g.DpiY / 96.

Well I do practically the same.
SizeF scale = new SizeF(g.DpiX / DOTSPERINCH, g.DpiY / DOTSPERINCH);

But I've also found using OnParentChanged very useful as well eg
if (((Form)Parent).AutoScaleDimensions.Width == 192f)
{
this.ScaleControl(new SizeF(2f, 2f), BoundsSpecified.Height);
this.shadowPen.Width = 2f;
this.framePen.Width = 2f;
}

I've now got both devices sitting side by side and just swap them over and
retest as I go. That's not too bad once you get used to it.When I got my
4700 I never thought I was going to use the 5450 again and thought I'd sell
it, but I'm glad I kept it. Active sync does a pretty neat job of handling
the swapping, plus my phone. Not so sure the older versions of AS would have
handled all that swapping.

I am already using Michelangelo. My real problem was that I had crappy icons
in the first place. I'm going to get a professional icon maker to make me
some new ones. My icon drawing efforts are like "don't give up your day job"

Graham
 
S

Simon Hart

Hi Graham,

Its not strictly VS2003 which double buffers the screen its Win CE that does
it depending on a setting in the .INF file which is used to build your
applications CAB file.

What it means is that your legacy apps will work on hires new devices
without code change, simply by double buffering the controls, (multipling
the coorindates by the form factor).

But this is all dependant on the INF file. see here:
http://msdn.microsoft.com/library/d...us/dnnetcomp/html/deploy_cf2_apps_cab_msi.asp -
this should help.

The above solution is a little messy and somewhat restrictive unless lots of
effort is put into it. I certainly would not recommend it for a award
winning application unless your audience is technical. I have finally got
InstallShield X to work with VS2005 by means of passing it my hand madeCAB
file and letting InstallSheild do the rest.

Cheers
Simon.
 

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