4

I'm developing audio plugins that run within a host such as Cubase, and I'm looking to add High DPI support. This is problematic because all host applications that I know of declare themselves as non-high DPI aware, so all windows are scaled automatically by the DWM. I'm looking for a way to turn off DWM DPI scaling for the plugin window, even if the host itself is not DPI-aware (so it uses DWM DPI scaling for all other windows). Does anyone know if this is possible at all?

For applications that use a lot of plugins, such as audio hosts, this is a very real problem because they can't just go ahead and declare themselves as high-DPI aware: this would break all existing plugins. So unless Windows provides a solution for this, we're always stuck in 96 dpi land. Basically I think we need a solution that is more fine-grained than setting this per-process, so the host and plugins can individually declare their awareness level.

In case this currently can't be done, is there a way to contact a Microsoft engineer so it could be added to a future version of Windows?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Frederik Slijkerman
  • 6,471
  • 28
  • 39
  • 1
    [Microsoft Products Accepting Bugs and Suggestions](http://connect.microsoft.com/). – IInspectable Oct 30 '14 at 08:26
  • Great link, but unfortunately only a few of Microsoft's products seem to participate. There's nothing for Windows in general as far as I can see. – Frederik Slijkerman Oct 30 '14 at 09:38
  • 7
    DPI awareness is process-wide instead of per-window because when you call `GetCursorPos()`, how does the system know which window's DPI to consult? There is no window handle parameter. The problem is unsolvable. – Raymond Chen Oct 30 '14 at 20:56
  • Thanks Raymond. I think coming from you this must be the definite answer. :-) If you post this as the answer, I'd accept it. – Frederik Slijkerman Nov 04 '14 at 14:18
  • 1
    I expect that since the Windows 8.1 implementation is such a mess, that not even Windows 8.1's control panel supports per-monitor-DPI-awareness, without glitches aplenty, that this will all get rebuilt again in Windows 10. Oh the fun. For fun, try taking the Screen Resolution window and drag it from a 96 dpi monitor to a 150+ dpi monitor, and back again. – Warren P Nov 11 '14 at 19:44
  • I agree that the per-monitor support wasn't really thought through. For some reason, the window caption will not scale for example, which looks quite silly. Apple really got it right with their Retina support. – Frederik Slijkerman Nov 13 '14 at 07:52
  • Is it possible to implement your plugin out of process? If you have a process division (even with a shared HWND) your problem is solvable. – morechilli Aug 04 '16 at 13:49
  • That's indeed the way to solve this with host application support. – Frederik Slijkerman Aug 12 '16 at 14:59
  • See the following lines from msdn (https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx). "Previous versions of Windows required you to set the DPI awareness for the entire application. Now the DPI awareness is tied to individual threads, processes, or windows" It clearly says that it is possible to set per window DPI awareness. We just need to figure out the "how". – Sahil Singh Dec 21 '16 at 13:46

2 Answers2

5

Per window DPI awareness is now possible, since Windows 10 anniversary update. A new API SetThreadDpiAwarenessContext() can be used to set per window,and per thread DPI awareness. This is accomplished as follows.

  • A thread can now dynamically change its DPI awarensss.
  • DPI awareness of a window created by the thread will depend on the DPI awareness of the calling thread at the time windows was created.
  • When windows procedure for a window is called, the thread is automatically switched to the DPI awareness context that was in use when the window was created.

Read the following references.

Sahil Singh
  • 3,352
  • 39
  • 62
  • 2
    Interesting blog post here: https://blogs.windows.com/buildingapps/2016/10/24/high-dpi-scaling-improvements-for-desktop-applications-and-mixed-mode-dpi-scaling-in-the-windows-10-anniversary-update/#UV05dJAwjyUskhrJ.97 – Frederik Slijkerman Jan 10 '17 at 15:01
2

You are out of luck here. DPI awareness is a process wide setting. In Windows 8.1 you can declare the process to be DPI aware on a per monitor basis.

And as Raymond comments above, no amount of engineering would enable API functions like GetCursorPos to have per-window DPI awareness, since such functions are not passed windows.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490