Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
627 views
in Technique[技术] by (71.8m points)

winapi - Declaring high DPI awareness per window on Windows 8

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...