ScrollWindowEx

  int ScrollWindowEx(hwnd, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate, fuScroll);    
  HWND hwnd; /* handle of window to scroll */
  int dx; /* amount of horizontal scrolling */
  int dy; /* amount of vertical scrolling */
  CONST RECT *lprcScroll; /* address of structure with scroll rectangle */
  CONST RECT *lprcClip; /* address of structure with clip rectangle */
  HRGN hrgnUpdate; /* handle of update region */
  LPRECT lprcUpdate; /* address of structure for update rectangle */
  UINT fuScroll; /* scrolling flags */

The ScrollWindowEx function scrolls the contents of the given window's client area. This function is similar to the ScrollWindow function, with some additional features.

Parameters

hwnd

Identifies the window to be scrolled.

dx

Specifies the amount, in device units, of horizontal scrolling. This parameter must be a negative value to scroll to the left.

dy

Specifies the amount, in device units, of vertical scrolling. This parameter must be a negative value to scroll up.

lprcScroll

Points to a RECT structure that specifies the portion of the client area to be scrolled. If this parameter is NULL, the entire client area is scrolled. The RECT structure has the following form:

typedef struct tagRECT { /* rc */

LONG left;

LONG top;

LONG right;

LONG bottom;

} RECT;

lprcClip

Points to a RECT structure that specifies the clipping rectangle to be scrolled. This structure takes precedence over the rectangle pointed to by the lprcScroll parameter. Only bits inside this rectangle are scrolled. Bits outside this rectangle are not affected even if they are in the lprcScroll rectangle. If this parameter is NULL, no clipping is performed on the scroll rectangle.

hrgnUpdate

Identifies the region that is modified to hold the region invalidated by scrolling. This parameter may be NULL.

lprcUpdate

Points to a RECT structure that will receive the boundaries of the rectangle invalidated by scrolling. This parameter may be NULL.

fuScroll

Specifies flags that control scrolling. This parameter can be one of the following values:

Value Meaning

SW_ERASE  
  When specified with SW_INVALIDATE, this flag erases the newly invalidated region by sending a WM_ERASEBKGND message to the window.
SW_INVALIDATE  
  Invalidates the region identified by the hrgnUpdate parameter after scrolling.
SW_SCROLLCHILDREN  
  Scrolls all child windows that intersect the rectangle pointed to by the lprcScroll parameter by the number of pixels specified by the dx and dy parameters. Windows sends a WM_MOVE message to all child windows that intersect the lprcScroll rectangle, even if they do not move.

Return Value

The return value is SIMPLEREGION (rectangular invalidated region), COMPLEXREGION (nonrectangular invalidated region; overlapping rectangles), or NULLREGION (no invalidated region), if the function is successful. Otherwise, the return value is ERROR.

Comments

If SW_INVALIDATE and SW_ERASE are not specified, ScrollWindowEx does not invalidate the area that is scrolled away from. If either of these flags is set, ScrollWindowEx invalidates this area. The area is not updated until the application calls the UpdateWindow function, calls the RedrawWindow function (specifying RDW_UPDATENOW or RDW_ERASENOW), or retrieves the WM_PAINT message from the application queue.

If the window has the WS_CLIPCHILDREN style, the returned areas specified by hrgnUpdate and lprcUpdate represent the total area of the scrolled window that must be updated, including any areas in child windows that need updating.

If the SW_SCROLLCHILDREN flag is specified, Windows will not properly update the screen if part of a child window is scrolled. The part of the scrolled child window that lies outside the source rectangle will not be erased and will not be redrawn properly in its new destination. Use the DeferWindowPos function to move child windows that do not lie completely within the lprcScroll rectangle. The cursor is repositioned if the SW_SCROLLCHILDREN flag is set and the caret rectangle intersects the scroll rectangle.

All input and output coordinates (for lprcScroll, lprcClip, lprcUpdate, and hrgnUpdate) are assumed to be in client coordinates, regardless of whether the window has the CS_OWNDC or CS_CLASSDC class style. Use the LPtoDP and DPtoLP functions to convert to and from logical coordinates, if necessary.

See Also

DPtoLP, LPtoDP, RedrawWindow, ScrollDC, ScrollWindow, UpdateWindow