Reputation: 476
I have a Windows Forms application (written in vs2010/C# against .NET framework 3.5) with one main form. It was designed at Win7's 100% DPI setting (I believe that's 96 dpi). When switching the computer to 150%, everything appears to scale just fine and all proportions are kept.
However, when I switch to 125%, some of the controls suddenly don't scale and appear to be as big as they would be at 100%. This messes up the whole layout, and hides some controls from the user.
Is there any kind of logical explanation as to the large difference in behavior between the 125% and 150% settings?
Also, is there a quicker way to test this? Having to log off and back in again every time I switch is quickly becoming annoying.
Upvotes: 3
Views: 2473
Reputation: 187
With respect to "Also, is there a quicker way to test this? Having to log off and back in again every time I switch is quickly becoming annoying."
Best thing is to use a Virtual Machine with a different DPI settings. You just run your application from the 'real' machine.
Upvotes: 0
Reputation: 942197
There's no simple explanation for what you observe.
A cheap way to test this without having to go through the painful login cycle is to change the form's Font property in the OnLoad method:
protected override void OnLoad(EventArgs e) {
this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * 120f / 96f);
base.OnLoad(e);
}
Upvotes: 3
Reputation:
Add to John Arlen's post:
You may also want to allow the form to Grow and Shrink, using the AutoSizeMode.
Upvotes: 0
Reputation: 6698
Look at form's AutoScaleMode. It is probably set to Font or Dpi
Upvotes: 2