GetUpdateRect function (winuser.h)

The GetUpdateRect function retrieves the coordinates of the smallest rectangle that completely encloses the update region of the specified window. GetUpdateRect retrieves the rectangle in logical coordinates. If there is no update region, GetUpdateRect retrieves an empty rectangle (sets all coordinates to zero).

Syntax

BOOL GetUpdateRect(
  [in]  HWND   hWnd,
  [out] LPRECT lpRect,
  [in]  BOOL   bErase
);

Parameters

[in] hWnd

Handle to the window whose update region is to be retrieved.

[out] lpRect

Pointer to the RECT structure that receives the coordinates, in device units, of the enclosing rectangle.

An application can set this parameter to NULL to determine whether an update region exists for the window. If this parameter is NULL, GetUpdateRect returns nonzero if an update region exists, and zero if one does not. This provides a simple and efficient means of determining whether a WM_PAINT message resulted from an invalid area.

[in] bErase

Specifies whether the background in the update region is to be erased. If this parameter is TRUE and the update region is not empty, GetUpdateRect sends a WM_ERASEBKGND message to the specified window to erase the background.

Return value

If the update region is not empty, the return value is nonzero.

If there is no update region, the return value is zero.

Remarks

The update rectangle retrieved by the BeginPaint function is identical to that retrieved by GetUpdateRect.

BeginPaint automatically validates the update region, so any call to GetUpdateRect made immediately after the call to BeginPaint retrieves an empty update region.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-draw-l1-1-0 (introduced in Windows 8)

See also

BeginPaint

GetUpdateRgn

InvalidateRect

Painting and Drawing Functions

Painting and Drawing Overview

RECT

UpdateWindow

ValidateRect