visual studio designer dpi setting
I've learn how to manage different DPI settings the hard way, so 开发者_JS百科that at runtime my applications are properly displayed.
But there is still a big issue with Design time Visual Studio. Say I build an application at 96 dpi and I switch my display to 120 dpi for testing purposes.
Now IF I open a form designer at 120 dpi, the form is resized according to 125%, the controls moved aso! :-(((
So I try to avoid reopening forms, but that's NOT a nice solution, isn't it?
Is there by any chance a design time setting to prevent form to resize?
Not a solution but possibly a workaround: do not test on your computer but on a VM or other computer and do not open the solution on a computer with big fonts.
And we found that we cannot use the AutoScaleMode = Dpi.Font setting. That will randomly resize forms when we open them in the designer. Dpi or None seem to work.
Although this question is already old, I want to share my workaround.
- Keep the Form’s
AutoScaleMode = Font
. This works fine, if you control the rest correctly. - Set in your Forms Designer:
Font = MS Sans; 11px
. Basically, specify your Fonts in Pixel, instead of Points. So Visual Studio won't re-scale anything if the system's DPI change. - In the Forms Ctor, after
InitializeComponent
, re-set:Font = SystemFonts.DefaultFont
. Now, at run time, Fonts will use Point-based sizes again, and you get nice high-DPI GUI. - Enable DPI-Awareness, either through a manifest or by API function SetProcessDPIAwareness
You can find the details of my (hard) learning trail on my Blog: http://www.sgrottel.de/?p=1581&lang=en
精彩评论