title: How to create a scaling and size-changing Per-Monitor DPI-aware application that is backwards compatible with Windows 7?
body: <p>I'm new to WPF (and to DPI-awareness APIs) and am writing an application for running in Windows 7, 8.1, and 10. I use multiple monitors with different per-monitor DPI settings, and am interested in making my application as compatible as possible across desktop configurations.</p>
  
  <p>I already know that is possible to add a Manifest to a WPF application, uncomment the section for DPI awareness, and set it to <code>True/PM</code>. This successfully allows the program to be Per-Monitor DPI-aware in Windows 8.1 and 10 (thus looking clean and sharp over various monitors), but run as System-aware in Windows 7.</p>
  
  <p>But can we do one step better?
  Microsoft provides a <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ee308410(v=vs.85).aspx" rel="noreferrer">neat tutorial here that shows how to create a Per-Monitor DPI-Aware</a> WPF application.
  What they do is actually create a new object in C++ to replace <code>&lt;Window&gt;</code> that uses Windows 8.1 APIs to not only detect the DPI change between the monitors, but then to <em>re-size</em> the application at runtime, effectively matching the change in DPI.
  The end result is that not only is the app Per-DPI aware and sharp looking, but when switching between large and small monitors of various sizes, the app looks to the user to change the same physical size (in inches or centimeters) on screen.</p>
  
  <p>The downside to Microsoft's Win32 code is that it is not backwards compatible with Windows 7. Trying to run in 7 results in the application crashing.</p>
  
  <p>I've gone through <a href="http://www.drdobbs.com/windows/coding-for-high-dpi-displays-in-windows/240168736" rel="noreferrer">this article on Dr.Dobbs</a> and <a href="https://msdn.microsoft.com/en-us/magazine/dn574798.aspx" rel="noreferrer">this one by Kenny Karr</a> but don't understand the APIs well enough to make things work.</p>
  
  <p>Does anyone know of a way to do something similar to Microsoft's code, where in Windows 8.1 and newer, an application that is Per-Monitor aware will actually <em>change size</em> when moving between monitors, but runs as System-Aware in Windows 7?</p>