Class WindowsDpiManager
Declares the process DPI aware from code, and reports whether it is - the two things about DPI that are Windows-only.
public static class WindowsDpiManager
- Inheritance
-
WindowsDpiManager
Remarks
Windows stretches the window of a process that has not declared itself DPI aware, which on a
150% display means a blurred, upscaled image. The declaration usually lives in an
app.manifest referenced from the project, as Stride's templates do;
EnablePerMonitorV2() is the same declaration made from code, for file-based apps and
anything else with no project file to hold a manifest. Either way it has to happen before the
window exists.
Reading the display's scale is not Windows-only and does not live here: see
DisplayScale in the core package, which the text overlay follows by default.
Methods
EnablePerMonitorV2()
Enables Per-Monitor-V2 DPI awareness for the current process (Windows 10+). Falls back to Per-Monitor if V2 is unavailable. This method is a best-effort call and does not throw on unsupported platforms or failures.
public static void EnablePerMonitorV2()
Remarks
Call it before the game is created - Windows refuses the change once the process has a window.
It is also refused when an app.manifest has already made a declaration, and the manifest's
setting then stands - if that manifest asks only for PerMonitor, the process stays on the
older mode rather than getting V2. Use one route, not both. Off Windows it does nothing: there is
nothing to declare there.
GetProcessDpiAwareness()
Gets the current process DPI awareness level - the way to check that a manifest or EnablePerMonitorV2() actually took effect.
public static WindowsDpiManager.ProcessDpiAwareness? GetProcessDpiAwareness()
Returns
- WindowsDpiManager.ProcessDpiAwareness?
The current WindowsDpiManager.ProcessDpiAwareness value when available; otherwise
null.
LogDpiInfo(string)
Logs the process DPI awareness to the console, for checking that the declaration took.
public static void LogDpiInfo(string prefix = "")
Parameters
prefixstringOptional message prefix.