Show / Hide Table of Contents

Struct Dpi.AwarenessContext

Can be used to temporarily change thread's DPI awareness context with API SetThreadDpiAwarenessContext. Does nothing if the API is unavailable (added in Windows 10 version 1607).

public struct Dpi.AwarenessContext : IDisposable
Remarks

Programs that use this library should use manifest with dpiAwareness = PerMonitorV2 and dpiAware = True/PM. Then default DPI awareness context is DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2.

Examples
using var dac = new Dpi.AwarenessContext(-1);

Namespace: Au.More
Assembly: Au.dll

Constructors

Name Description
AwarenessContext(wnd)

If Dpi.AwarenessContext.Available, calls API GetWindowDpiAwarenessContext and SetThreadDpiAwarenessContext. Sets the awareness context of this thread equal to that of the window.

AwarenessContext(nint)

If Dpi.AwarenessContext.Available, calls API SetThreadDpiAwarenessContext.

Properties

Name Description
Available

Returns true if thread DPI awareness contexts are available on this Windows version (Windows 10 1607 and later).

Methods

Name Description
Dispose()

Restores previous DPI awareness context.