GetDpiForWindow function

Returns the dots per inch (dpi) value for the associated window.

Syntax


UINT WINAPI GetDpiForWindow(
  _In_ HWND hwnd
);

Parameters

hwnd [in]

The window you want to get information about.

Return value

The DPI for the window which depends on the DPI_AWARENESS of the window. See the Remarks for more information. An invalid hwnd value will result in a return value of 0.

Remarks

The following table indicates the return value of GetDpiForWindow based on the DPI_AWARENESS of the provided hwnd.

DPI_AWARENESSReturn value
DPI_AWARENESS_UNAWARE96
DPI_AWARENESS_SYSTEM_AWAREThe system DPI.
DPI_AWARENESS_PER_MONITOR_AWAREThe DPI of the monitor where the window is located.

 

Requirements

Minimum supported client

Windows 10 [desktop apps only]

Minimum supported server

None supported

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

DPI_AWARENESS

 

 

Show: