RE: Scaling problem - font size

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: JohnReb (JohnReb_at_discussions.microsoft.com)
Date: 09/03/04


Date: Fri, 3 Sep 2004 12:21:05 -0700

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:

> 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
>
>
>



Relevant Pages

  • inherit without calling parent class constructor?
    ... I need to create many instances of a class D that inherits from a class ... Since the constructor of B is expensive I'd like to execute it only ... Here's another workaround: ...
    (comp.lang.python)
  • Re: Question about inheritance
    ... The very first statement in the body of a constructor is always the call to ... create a separate method that does something ... and derived constructors. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need a project... found a website on mindprod
    ... public void HelloWorld() ... Constructor call must be the first statement in a constructor ... WTF... ...
    (comp.lang.java.help)
  • Re: Any experience with "The Last One"?
    ... >3 It is implementation-defined whether the dynamic initialization ... > the first statement of main or deferred to any point in time after the ... SampleClass, so the constructor cannot be called before it, and ... I would argue that this should apply also to a function of SampleClass, ...
    (comp.programming)
  • Re: Any experience with "The Last One"?
    ... >3 It is implementation-defined whether the dynamic initialization ... > the first statement of main or deferred to any point in time after the ... SampleClass, so the constructor cannot be called before it, and ... I would argue that this should apply also to a function of SampleClass, ...
    (comp.lang.c)