AdjustWindowRectExForDpi function (winuser.h)

Calculates the required size of the window rectangle, based on the desired size of the client rectangle and the provided DPI. This window rectangle can then be passed to the CreateWindowEx function to create a window with a client area of the desired size.

Syntax

BOOL AdjustWindowRectExForDpi(
  [in, out] LPRECT lpRect,
  [in]      DWORD  dwStyle,
  [in]      BOOL   bMenu,
  [in]      DWORD  dwExStyle,
  [in]      UINT   dpi
);

Parameters

[in, out] lpRect

A pointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.

[in] dwStyle

The Window Style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style.

[in] bMenu

Indicates whether the window has a menu.

[in] dwExStyle

The Extended Window Style of the window whose required size is to be calculated.

[in] dpi

The DPI to use for scaling.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

This function returns the same result as AdjustWindowRectEx but scales it according to an arbitrary DPI you provide if appropriate.

Requirements

Requirement Value
Minimum supported client Windows 10, version 1607 [desktop apps only]
Minimum supported server Windows Server 2016 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll