I created an application that works perfectly until the user selects 125% or 150%. It would break my application. I later found a way to find the font size by detecting the
For C++/Win32 users, here is a good reference: Writing High-DPI Win32 Applications.
The correct way of handling variable DPI settings is not to detect them and adjust your controls' sizes manually in a switch
statement (for starters, there are far more possibilities than those you show in your sample if
statement).
Instead, you should set the AutoScaleMode property of your form to AutoScaleMode.Dpi
and let the framework take care of this for you.
Add the following code to your form's constructor (or set this property at design time):
this.AutoScaleMode = AutoScaleMode.Dpi;
Although you might prefer to use AutoScaleMode.Font
. For more information on automatic scaling, see the MSDN documentation.
if your on a newer version of windows I recommend reinstalling your graphics card drivers ( e.g installing a newer version) I had the same problem, my display scale was set to 100% but the font was way off. hope this fixes your problem