Scaling problem - font size

M

M O J O

Hi,

I have my windows-display-font-size set to "Large fonts" and I've created a
new project with two forms. Both of them are 600 width and 400 height. One
have autoscale=true and the other is false. When I run the project, the two
forms shows the same size.

Now I open the project (in vs.net) on a computer with
windows-display-font-size set to "Small fonts" and my project is screwed up.
Now the width is 501 and the height is 351????????!!!!! When I run the
project, the form with autoscale=true is smaller, which I can understand.

My question is .... why isn't my form size 600x400 when I open it on a
computer with "Small fonts"? ... and how can I make it the same size?

Lets say two develloper worked on the same project. One use "Large fonts"
and the other "Small fonts". How can I make vs.net show the forms at the
same size on both devellopers vs.net??

STRANGE! :blush:)

Thanks in advance!

M O J O
 
K

Kevin Yu [MSFT]

Hi MOJO,

Based on your discription, I'm still not quite sure about the problem.
Could you tell me which window's size changed to 501*351? The one with
AutoScale set to true or false?

If it is the true one, it's because the size of the window is actually
changing. I didn't reproduced it on my machine when I set AutoScale to
false.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

M O J O

Hi Kevin,

I'm sorry for beeing unclear.

Here's my question again....

I have a desktop computer with "Large fonts" and a laptop with "Small
fonts".

If I create a new project on my desktop and set the form size to 600x400
then when I open the same form (in vs.net form designer) on my laptop, it's
501x351 regardless of AutoScale is set to true or false.

In my search for a solution, I've stumbled over, that it must have somethig
to do with the AutoScaleBaseSize. I just can't figure out what to do.

I want to be able to open the form on my desktop and my laptop and keep the
size to 600x400, regardless of font sizes.

Hope you understand. :blush:)

Thanks!!!!

M O J O
 
L

Lewis Moten

MOJO,

There may be a difference in the borders arround your forms. Try out
the following code to see if this helps you with your problem.

private void Form1_Load(object sender, System.EventArgs e)
{
Width = 640 - (Width - ClientSize.Width);
Height = 400 - (Height - ClientSize.Height);
}
 
G

Guest

I have had this same problem, and have found that the following workaround is
reasonably successful:

In every constructor of every form, as the first statement after the call to
InitializeComponent () add:

SizeF sf = Form.GetAutoScaleSize (this.Font);
this.AutoScaleBaseSize = sf.ToSize ();

I created a class with a static method so I can make it in one line, since
it is used a lot:

this.AutoScaleBaseSize = autoScaleHelpClass.GetBaseSize (this.Font);


After adding this, my app works pretty well among large and small font
systems, at multiple resolutions. Not perfect, but pretty good.

Hope this helps.
John
 
K

Kevin Yu [MSFT]

Hi MOJO,

I agree with John, that we should also set AutoScaleBaseSize according to
the form font to resolve this issue. According to John's suggestion, we
have to add the following lines of code when form loads to make the form
fit.

SizeF sf = Form.GetAutoScaleSize (this.Font);
this.AutoScaleBaseSize = sf.ToSize ();
this.AutoScale = true;

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

M O J O

Hi John,

Thank you for answering my post!!!!

Unfortunately I cannot see any difference in doing what you suggested.

Please se my answer to Kevin.

Thanks anyway!!!!!

M O J O
 
M

M O J O

Hi Kevin,

I tried to upload a couple of gif files to show what I mean, but MS' server
rejected the attachments.....hmmm.

I do not understand, that when I tell the form it should be 600x400 why the
form size changes under different font sizes.

The code you and John showed me only affects runtime, but in designtime
things look wird when going from "large fonts" to "small fonts".

M O J O
 
K

Kevin Yu [MSFT]

Hi MOJO,

When fonts changes, we need to write additional codes to make size change
in design time. However, I think these codes are not provided in current
controls. So when the fonts changed when design time, there is no changes
of the size accordingly.

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

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