GetDpiForWindowhwnd
GetDpiForWindow is a Windows API function used to retrieve the DPI (dots per inch) value currently in effect for a specific window. It enables per-window DPI awareness by returning the DPI for the window’s display context, rather than a system-wide setting.
The function prototype is UINT GetDpiForWindow(HWND hWnd); where hWnd is a handle to the window for which
Return value and behavior: The function returns the window’s DPI as an unsigned integer, typically values like
Usage notes: GetDpiForWindow is useful for scaling UI elements to match the actual display density of a
Requirements and availability: GetDpiForWindow is available on Windows 10 and later. Include Windows.h in your source
Example usage: UINT dpi = GetDpiForWindow(hwnd); This value can be used to scale fonts, controls, and graphics