Normal Size vs. Large Size fonts

N

N4709L

We are having a problem with the size of forms when we develop our VB.NET
application on developer stations which use Normal Size (96 DPI) fonts and
the application is subsequently run on user stations that are configured to
use Large Size (120 DPI) fonts.

What happens is the form itself is too small to display all of the controls
that are on the form. One must resize the form to view all of the controls!
We would have thought that if the form layout looks correct on the
developer's station using Normal Size fonts and is built and deployed, it
would not matter what font size setting is used on the User's station.

These forms have a MaximumSize and a MinimumSize specified. For example, a
typical form might have the following property settings:
MaximumSize 1024,400
MinimumSize 344,400
Size 480,400

This particular form may be resized in width only. The MinimumSize.Height
and MaximumSize.Height matches Me.Height and on the developer's workstation,
the height of the form is just right! We do not want the user to be able to
change the height of the form. There's no need to!

When run on a User's station where Large Fonts are used, not all of the
form's controls may be seen. In this case, because the form cannot be
resized in Height, the user can never get to the OK button at the bottom of
the form! If we let MaximumSize.Height be larger at design time, the form
can be resized and the Large Fonts user can resize the form to get to the OK
button. But this isn't nice, because it should not be necessary to resize
the form, and because the form can easily be resized so that it looks "bad".

What's going on here and why does the form appear on the screen at a
different size when the Font Size changes? None of the other controls are
painted incorrectly. Only the form (border) itself is incorrectly sized.

Thanks!
 
D

Daniel Carlsson

Try changing the forms AutoScale property, then the form should rescale with
the font. Im not sure if it will change the height if you have maxheight set
to a lower value though.

/Dan
 
Y

Ying-Shen Yu[MSFT]

Hi,

From your description, my understanding to your problem now is your problem
layout incorrectly if you set the MaximumSize and MinimumSize on your
develop machine but run on a Hi-DPI display machine.

To support hi-dpi device it's not recommended to hardcode the window size,
windows forms has the ability to auto scale on different DPI, but you set
the MaxmumSize and MinimumSize property at design-time so it locked the
form size. I'd like to know if the form scales correctly on the Hi-Dpi
display if you didn't set the MaxSize /MinSize property? If yes, I also
guess you just want to prevent the user resizing the form, not prevent the
auto-layouting right? If so you may try setting these two property at
runtime with some calculation based on the actuall Form.Size at run-time,
such as write
this.MaximumSize = this.Size;
in the constructor of the Form will set the max size based on the initial
size at run-time.

Does it solve your problem?


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
Y

Ying-Shen Yu[MSFT]

Hi,

Forget to say, like Daniel said, you need set AutoScale to True to turn on
this feature.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
N

N4709L

I'll work on this today. Yes, you understand the situation correctly. I do
want to have the form autosize based on the font size, but yes, I do want to
prevent the user from resizing the form below a specified size (where the
controls get covered up) or making a form get taller where there is no need
(only gray area appears).

By "constructor" do you mean the form's Load event? Or the auto-generated
code that the VS IDE prepares?
 
Y

Ying-Shen Yu[MSFT]

Hi,

Thanks for your reply.
the constructor referrs to the Sub New method in VB.NET,
The method that calls InitializeComponent.
It's ok to set MaximumSize/MinimumSize in On_Load event handler, too.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
Y

Ying-Shen Yu[MSFT]

Hi,

Besides, I'd like to say Windows Forms has rich Layout support, it provides
some simple properties to help you layout the controls when form is
resized, it also provides ways to let you define customize layout. You may
read this article written by Chris sells to get some idea on layout

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/htm
l/winforms12102002.asp

And here is an advance topic on how to customize the layout in windows
forms by Chris Anderson.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/custlaywinforms.asp

I hope these information will be helpful to this issue.
Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
N

N4709L

Thanks! I've gotten it to work perfectly by setting the MinimumSize and
MaxiumumSize properties at run-time in the Form Load event, as you
described. Setting these properties at Design Time in the IDE doesn't
achieve the correct result when the application is run on Normal Size and
Large Size Font systems. That's a subtle issue that I believe few realize!
I'm glad we've got a good handle on this now.

Thanks very much for the articles. Very helpful!
-Ron
 

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