title: Can I automatically scale a form for DPI without it getting blurry?
body: <p>I am developing a WinForms application in C#. It uses a panel to draw an image of the Mandelbrot fractal. In the manual for the program and whenever I post about it somewhere, I recommend people to set their scaling setting to 100%, as otherwise the images won't look nice. This is because on other settings, the image is scaled up after drawing it, and it becomes blurry. All other controls are blurry too. </p>
  
  <p>For example: my panel is 500x500. The scaling in my Windows is set to 125%. When I run the program, the panel is internally still 500x500, but it appears as 625x625, blurry. <br> Instead, when the program is run, I want the panel to internally resize to 625x625, and appear as 625x625 too.</p>
  
  <p>I have found the following solution: I found out about SetProcessDPIAware() (from <a href="http://crsouza.com/2015/04/13/how-to-fix-blurry-windows-forms-windows-in-high-dpi-settings/" rel="nofollow noreferrer">here</a>). Setting that makes the window not scale (it appears as if it was at the 100% scale setting), but the text does (and without becoming blurry). I can then, at the start of the program, calculate the appropriate multiplier (dpi = DpiX / 96) and give that to a huge method that includes commands like </p>
  
  <pre><code>xentrylabel.Location = new Point((int)(xentrylabel.Location.X * dpi),(int)(xentrylabel.Location.Y * dpi));
  xentry.Location = new Point((int)(xentry.Location.X * dpi), (int)(xentry.Location.Y * dpi));
  xentry.Size = new Size((int)(xentry.Width * dpi), (int)(xentry.Height * dpi));
  </code></pre>
  
  <p>One for every control property that might need to be updated. While writing this question, I got this idea and got started with it. However, I realised that this will need very many lines of code, so I wonder if there isn't a built-in way to do this. It seems like an option that many would like to go for, rather than their applications becoming blurry or hard to read on screens with high dpi.</p>
  
  <p>Is this way of manually correcting positions and sizes the way to go, or is there a built-in way to scale the form for other DPI settings by actually scaling everything in the form, instead of scaling the end result?</p>
  
  <p>Edit: From some comments it seems as if SetProcessDPIAware() alone should scale up everything. But in my experience, it doesn't. Here are some screenshots:
  Application on 100% scale setting:
  <a href="https://i.stack.imgur.com/pws9B.png" rel="nofollow noreferrer">https://i.stack.imgur.com/pws9B.png</a></p>
  
  <p>Application on 125% scale setting without SetProcessDPIAware():
  <a href="https://i.stack.imgur.com/cE4Wx.png" rel="nofollow noreferrer">https://i.stack.imgur.com/cE4Wx.png</a></p>
  
  <p>Application on 125% scale setting with SetProcessDPIAware():
  <a href="https://i.stack.imgur.com/oVA8W.png" rel="nofollow noreferrer">https://i.stack.imgur.com/oVA8W.png</a></p>