ScrollWindow

Syntax

void ScrollWindow(hWnd,XAmount,YAmount,lpRect,lpClipRect)

This function scrolls a window by moving the contents of the window's client area the number of units specified by the XAmount parameter along the screen's x-axis and the number of units specified by the YAmount parameter 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.

Parameter Type/Description  

hWnd HWND Identifies the window whose client area is to be scrolled.  
XAmount int Specifies the amount (in device units) to scroll in the x direction.  
YAmount int Specifies the amount (in device units) to scroll in the y direction.  
lpRect LPRECT Points to a RECT data structure that specifies the portion of the client area to be scrolled. If lpRect is NULL, the entire client area is scrolled.  
lpClipRect LPRECT Points to a RECT data 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.  

Return Value

None.

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 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 lpRect parameter 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 window are also offset. ScrollWindow is faster when lpRect is NULL.

If the lpRect 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 lpRect is not NULL, call the UpdateWindow function to repaint the window before calling ScrollWindow.