InvalidateRect

Syntax

void InvalidateRect(hWnd,lpRect,bErase)

This function invalidates the client area within the given rectangle by adding that rectangle to the window's update region. The invalidated rectangle, along with all other areas in the update region, is marked for painting when the next WM_PAINT message occurs. The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs, or the region is validated by using the ValidateRect or ValidateRgn function.

The bErase parameter specifies whether the background within the update area is to be erased when the update region is processed. If bErase is nonzero, the background is erased when the BeginPaint function is called; if bErase is zero, the background remains unchanged. If bErase is nonzero for any part of the update region, the background in the entire region is erased, not just in the given part.

Parameter Type/Description  

hWnd HWND Identifies the window whose update region is to be modified.  
lpRect LPRECT Points to a RECT data structure that contains the rectangle (in client coordinates) to be added to the update region. If the lpRect parameter is NULL, the entire client area is added to the region.  
bErase BOOL Specifies whether the background within the update region is to be erased.  

Return Value

None.

Comments

Windows sends a WM_PAINT message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.