How to automatically scale .NET forms using Windows' cus

Posted by Tung on 30-Jan-2013 09:28

If a user is running Windows with a custom text size like 125%, your .NET application can scale up automatically.


In your forms and user controls' constructor, add the following lines.

THIS-OBJECT:AutoScaleDimensions = NEW System.Drawing.SizeF(96, 96).

THIS-OBJECT:AutoScaleMode = System.Windows.Forms.AutoScaleMode:Dpi.


The first line sets the default DPI to 96 and the second tells them to scale up when the current DPI isn't the same as the default.


A couple of points:


It seems to work on Windows 7 only, as previous versions only change properties like font sizes.

And the code needs to go into a particular form class or call a method that has those lines. It didn't work when I put the code in a class that inherits from Progress.Windows.Form that I create other forms from.

There's more info here at 'Automatic Scaling in Windows Forms' http://msdn.microsoft.com/en-us/library/ms229605.aspx

All Replies

This thread is closed