BOOL 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 * lprcScroll; | /* address of structure with scroll rectangle | */ | |||
CONST RECT * lprcClip; | /* address of structure with clip rectangle | */ |
The ScrollWindow function scrolls the contents of the given window's client area.
hwnd
Identifies the window whose client area is 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, the entire window is scrolled.
The return value is TRUE if the function is successful, or FALSE if an error occurs. To obtain extended error information, use the GetLastError function.
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 scrolling 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 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.
UpdateWindow, ScrollDC, ScrollWindowEx