GetUpdateRect

2.x

  BOOL GetUpdateRect(hwnd, lprc, fErase)    
  HWND hwnd; /* handle of window, */  
  RECT FAR* lprc; /* address of structure for update rectangle */
  BOOL fErase; /* erase flag */

The GetUpdateRect function retrieves the coordinates of the smallest rectangle that completely encloses the update region of the given window. If the window was created with the CS_OWNDC style and the mapping mode is not MM_TEXT, GetUpdateRect gives the rectangle in logical coordinates; otherwise, GetUpdateRect gives the rectangle in client coordinates. If there is no update region, GetUpdateRect makes the rectangle empty (sets all coordinates to zero).

Parameters

hwnd

Identifies the window whose update region is to be retrieved.

lprc

Points to the RECT structure that receives the client coordinates of the enclosing rectangle. The RECT structure has the following form:

typedef struct tagRECT {    /* rc */
   int left;
   int top;
   int right;
   int bottom;
} RECT;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

An application can set this parameter to NULL to determine whether an update region exists for the window. If this parameter is NULL, the GetUpdateRect function 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.

fErase

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

Return Value

The return value is nonzero if the update region is not empty. Otherwise, it is zero.

Comments

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

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

See Also

BeginPaint, GetUpdateRgn, InvalidateRect, UpdateWindow, ValidateRect