all groups > dotnet drawing api > april 2008 >
You're in the

dotnet drawing api

group:

Windows DPI scaling



Windows DPI scaling Damien
4/21/2008 1:10:13 PM
dotnet drawing api: Hi,

C# .NET 2.0
I'm developing a windows application that will run on a number of
machines typically with DPI of either 96 or 120.
By setting the AutoScaleMode on different forms to DPI I get the
required scaling results. However, I have one form that contains a
richtextbox that's anchored to top, left and bottom borders and where
I change the width of the richtextbox depending on values taken from a
PageSetupDialog control. Something like this:

this.pageWidth = this.pageSetupDialog1.PageSettings.Bounds.Width
-
this.pageSetupDialog1.PageSettings.Margins.Left
-
this.pageSetupDialog1.PageSettings.Margins.Right;
this.txtWritingPad.Width = pageWidth;


The problem now is that a single line of text that fits on one single
line in 96 dpi gets wrapped to the second line in 120 dpi. Font and
font size are the same. I need the text/font to appear the same on
both machines. i.e. on one line from left to right.

I thought that maybe because I was explicitly setting the width of the
control at run time I would have to call PerformAutoScale() but that
doesn't seem to have any effect. I'm obviously missing something. Can
anybody help?

Thanks,
AddThis Social Bookmark Button