CWnd::ScrollWindow

Syntax

void ScrollWindow( int xAmount, int yAmount, LPRECT lpRect = NULL, LPRECT lpClipRect = NULL );

Parameters

xAmount

Specifies the amount (in device units) to scroll in the x-axis direction.

yAmount

Specifies the amount (in device units) to scroll in the y-axis direction.

lpRect

Points to a CRect or RECT structure that specifies the portion of the client area to be scrolled. If lpRect is NULL, the entire client area is scrolled.

lpClipRect

Points to a CRect or RECT structure that specifies the clipping rectangle to be scrolled. Only bits inside this rectangle are scrolled. If lpClipRect is NULL, the entire window is scrolled.

Remarks

Scrolls the current CWnd object by moving the contents of the window's client area the number of units specified by xAmount along the screen's x-axis and the number of units specified by yAmount along the y-axis. The scroll moves right if xAmount is positive and left if it is negative. The scroll moves down if yAmount is positive and up if it is negative.

If the caret is in the CWnd 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 member function is not repainted, but is combined into the current CWnd object's update region. The WM_PAINT message will be sent, notifying it that the region needs repainting. To repaint the uncovered area at the same time the scrolling is done, call the UpdateWindow member function immediately after calling ScrollWindow.

If lpRect is NULL, the positions of any child windows in the window are offset by the amount specified by xAmount and yAmount, and any invalid (unpainted) areas in the CWnd are also offset. ScrollWindow is faster when lpRect is NULL.

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

See Also

CWnd::UpdateWindow, ::ScrollWindow