Show / Hide Table of Contents

Class Dpi

Functions for high-DPI screen support.

public static class Dpi
Remarks

To find DPI % on Windows 10 and 11: Settings > System > Display > Scale and layout. If not 100%, it means high DPI.

This program must be per-monitor-DPI-aware. Else results are undefined.


Namespace: Au.More
Assembly: Au.dll
Inheritance
object
Dpi

Properties

Name Description
System

Gets DPI of the primary screen at the time this process started.

Methods

Name Description
AdjustWindowRectEx(DpiOf, ref RECT, WS, WSE, bool)

Calls API AdjustWindowRectExForDpi if available, else AdjustWindowRectEx.

GetSystemMetrics(int, DpiOf)

Calls API GetSystemMetricsForDpi if available, else GetSystemMetrics.

IsWindowVirtualized(wnd)

Detects whether the window is DPI-scaled/virtualized.

OfScreen(nint, bool)

Gets DPI of a screen.

OfWindow(wnd, bool)

Gets the DPI of a window, as used in the window's process. It never changes for that window instance.

OfWindow(DependencyObject)

Returns OfWindow(w.Hwnd()).

OfWindow(Control)

Returns OfWindow(w.Hwnd()).

Scale(RECT, DpiOf)

Scales RECT if the specified DPI isn't 96 (100%).

Scale(SIZE, DpiOf)

Scales SIZE if the specified DPI isn't 96 (100%).

Scale(int, DpiOf)

Scales int if the specified DPI isn't 96 (100%).

Scale(Size, DpiOf)

Scales System.Windows.Size if the specified DPI isn't 96 (100%).

SystemParametersInfo(uint, int, void*, DpiOf)

Calls API SystemParametersInfoForDpi if available, else SystemParametersInfo. Use only with uiAction = SPI_GETICONTITLELOGFONT, SPI_GETICONMETRICS, SPI_GETNONCLIENTMETRICS.

Unscale(RECT, DpiOf)

Unscales RECT if the specified DPI isn't 96 (100%).

Unscale(SIZE, DpiOf)

Unscales SIZE if the specified DPI isn't 96 (100%).

Unscale(int, DpiOf)

Unscales int if the specified DPI isn't 96 (100%).

WindowDpiAwareness(wnd)

Gets DPI awareness of a window.