RedrawWindow

3.1

  BOOL RedrawWindow(hwnd, lprcUpdate, hrgnUpdate, fuRedraw)    
  HWND hwnd; /* handle of window, */  
  const RECT FAR* lprcUpdate; /* address of structure with update rect. */
  HRGN hrgnUpdate; /* handle of update region */
  UINT fuRedraw; /* redraw flags, */  

The RedrawWindow function updates the specified rectangle or region in the given window's client area.

Parameters

hwnd

Identifies the window to be redrawn. If this parameter is NULL, the desktop window is updated.

lprcUpdate

Points to a RECT structure containing the coordinates of the update rectangle. This parameter is ignored if the hrgnUpdate parameter contains a valid region handle. 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.

hrgnUpdate

Identifies the update region. If both the hrgnUpdate and lprcUpdate parameters are NULL, the entire client area is added to the update region.

fuRedraw

Specifies one or more redraw flags. This parameter can be a combination of flags.

The following flags are used to invalidate the window:

Value Meaning

RDW_ERASE Causes the window to receive a WM_ERASEBKGND message when the window is repainted. The RDW_INVALIDATE flag must also be specified; otherwise, RDW_ERASE has no effect.
RDW_FRAME Causes any part of the non-client area of the window that intersects the update region to receive a WM_NCPAINT message. The RDW_INVALIDATE flag must also be specified; otherwise, RDW_FRAME has no effect. The WM_NCPAINT message is typically not sent during the execution of the RedrawWindow function unless either RDW_UPDATENOW or RDW_ERASENOW is specified.
RDW_INTERNALPAINT Causes a WM_PAINT message to be posted to the window regardless of whether the window contains an invalid region.
RDW_INVALIDATE Invalidate lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is invalidated.

The following flags are used to validate the window:

Value Meaning

RDW_NOERASE Suppresses any pending WM_ERASEBKGND messages.
RDW_NOFRAME Suppresses any pending WM_NCPAINT messages. This flag must be used with RDW_VALIDATE and is typically used with RDW_NOCHILDREN. This option should be used with care, as it could cause parts of a window from painting properly.
RDW_NOINTERNALPAINT Suppresses any pending internal WM_PAINT messages. This flag does not affect WM_PAINT messages resulting from invalid areas.
RDW_VALIDATE Validates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is validated. This flag does not affect internal WM_PAINT messages.

The following flags control when repainting occurs. No painting is performed by the RedrawWindow function unless one of these bits is specified.

Value Meaning

RDW_ERASENOW Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT and WM_ERASEBKGND messages, if necessary, before the function returns. WM_PAINT messages are deferred.
RDW_UPDATENOW Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT, WM_ERASEBKGND, and WM_PAINT messages, if necessary, before the function returns.

By default, the windows affected by the RedrawWindow function depend on whether the specified window has the WS_CLIPCHILDREN style. The child windows of WS_CLIPCHILDREN windows are not affected; however, non-WS_CLIPCHILDREN windows are recursively validated or invalidated until a WS_CLIPCHILDREN window is encountered. The following flags control which windows are affected by the RedrawWindow function:

Value Meaning

RDW_ALLCHILDREN Includes child windows, if any, in the repainting operation.
RDW_NOCHILDREN Excludes child windows, if any, from the repainting operation.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

When the RedrawWindow function is used to invalidate part of the desktop window, the desktop window does not receive a WM_PAINT message. To repaint the desktop, an application should use the RDW_ERASE flag to generate a WM_ERASEBKGND message.

See Also

GetUpdateRect, GetUpdateRgn, InvalidateRect, InvalidateRgn, UpdateWindow