Search:
Namespaces
Discussions
.NET v1.1
Feedback
Scaling problem - font size
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.general
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
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! :o)
Thanks in advance!
M O J O
Reply to this message...
JohnReb (VIP)
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
"M O J O" wrote:
[Original message clipped]
Reply to this message...
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
"JohnReb" <
Click here to reveal e-mail address
> skrev i en meddelelse
news:
Click here to reveal e-mail address
...
> I have had this same problem, and have found that the following workaround
is
[Original message clipped]
Reply to this message...
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);
}
"M O J O" <
Click here to reveal e-mail address
> wrote in message news:<
Click here to reveal e-mail address
>...
[Original message clipped]
Reply to this message...
Kevin Yu [MSFT] (VIP)
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."
Reply to this message...
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. :o)
Thanks!!!!
M O J O
"Kevin Yu [MSFT]" <
Click here to reveal e-mail address
> skrev i en meddelelse
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Kevin Yu [MSFT] (VIP)
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."
Reply to this message...
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
"Kevin Yu [MSFT]" <
Click here to reveal e-mail address
> skrev i en meddelelse
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Kevin Yu [MSFT] (VIP)
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."
Reply to this message...
M O J O
Thank you for your answer.
M O J O
"Kevin Yu [MSFT]" <
Click here to reveal e-mail address
> skrev i en meddelelse
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.Drawing.SizeF
System.EventArgs
System.Windows.Forms.Form
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com