简体   繁体   中英

How to prevent font resize when changing the DPI of the system

I have developed an application in C# .NET 3.5 and I would like it to maintain the same window size and font size even when the system DPI is changed. I've set AutoscaleMode to None in the main form. The form and controls are not resized but the size of all the texts is upscaled. Is there a way I can prevent texts to upscale or how can I control them to reset them to the size they have at 96dpi? Thanks.

A potentially easy solution is to change the font sizes of your controls proportionally to the changes in DPI. When the DPI changes, scale up/down your font sizes accordingly.

Another possible option is to "hard-render" all of the text on your controls as images. Then set scaled-up or scaled-down copies of the images as the BackgroundImage values of your controls. If you do this, be sure to set your controls' BackgroundImageLayout properties appropriately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM