1

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.

Andrea Nagar
  • 1,233
  • 2
  • 13
  • 23
  • 1
    That's a crappy thing to do to your users. I've adjusted DPI and font size before and apps that don't scale well with it are immediately on the "to be uninstalled ASAP" list. – Adam Lear Oct 18 '10 at 00:45
  • 3
    Is that not defeating the purpose of the DPI controls? – Dean Harding Oct 18 '10 at 00:46
  • I understand that but this is a precise requirement of my customer who wants the window to remain unchanged independently of the DPI of the system. – Andrea Nagar Oct 18 '10 at 02:56
  • +1 for Dean. Maybe you could get the current DPI and then adjust the font to a preset ratio? – Mike Oct 18 '10 at 06:06

1 Answers1

0

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.

Michael Hoffmann
  • 2,411
  • 2
  • 24
  • 42