ScrollWindow

2.x

  void ScrollWindow(hwnd, dx, dy, lprcScroll, lprcClip)    
  HWND hwnd; /* handle of window to scroll */
  int dx; /* amount of horizontal scrolling */
  int dy; /* amount of vertical scrolling */
  const RECT FAR* lprcScroll; /* address of structure with scroll rect. */
  const RECT FAR* lprcClip; /* address of structure with clip rect. */

The ScrollWindow function scrolls the contents of a window's client area.

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 caret is repositioned if the cursor rectangle intersects the scroll 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.

lprcClip

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

Return Value

This function does not return a value.

Comments

If the caret is in the window being scrolled, ScrollWindow automatically hides the caret to prevent it from being erased, then restores the caret after the scroll is finished. The caret position is adjusted accordingly.

The area uncovered by the ScrollWindow function is not repainted, but it is combined into the window's update region. The application will eventually receive a WM_PAINT message notifying it that the region needs repainting. To repaint the uncovered area at the same time the scrolling is done, call the UpdateWindow function immediately after calling ScrollWindow.

If the lprcScroll parameter is NULL, the positions of any child windows in the window are offset by the amount specified by the dx and dy parameters, and any invalid (unpainted) areas in the window are also offset. ScrollWindow is faster when lprcScroll is NULL.

If the lprcScroll parameter is not NULL, the positions of child windows are not changed and invalid areas in the window are not offset. To prevent updating problems when lprcScroll is not NULL, call the UpdateWindow function to repaint the window before calling ScrollWindow.

See Also

ScrollDC, ScrollWindowEx, UpdateWindow