int OffsetClipRgn(hdc, nXOffset, nYOffset) | ||||
HDC hdc; | /* device-context handle, */ | |||
int nXOffset; | /* offset along x-axis, */ | |||
int nYOffset; | /* offset along y-axis, */ |
The OffsetClipRgn function moves the clipping region of the given device by the specified offsets.
hdc
Identifies the device context.
nXOffset
Specifies the number of logical units to move left or right.
nYOffset
Specifies the number of logical units to move up or down.
The return value is SIMPLEREGION (region has no overlapping borders), COMPLEXREGION (region has overlapping borders), or NULLREGION (region is empty), if the function is successful. Otherwise, the return value is ERROR.
The following example creates an elliptical region and selects it as the clipping region for a device context. The OffsetClipRgn function is called repeatedly to move the clipping region from left to right across the screen. Because only the new clipping region is redrawn each time the Rectangle function is called, the left side of each ellipse remains on the screen when the clipping region moves. When the loop has finished, a wide blue line with rounded ends stretches from one side of the client area to the other.
RECT
rc; HRGN hrgn; HBRUSH hbr, hbrPrevious; int i; GetClientRect(hwnd, &rc); hrgn = CreateEllipticRgn(0, 100, 100, 200); SelectClipRgn(hdc, hrgn); hbr = CreateSolidBrush(RGB(0, 0, 255)); hbrPrevious = SelectObject(hdc, hbr); for (i = 0; i < rc.right - 100; i++) { OffsetClipRgn(hdc, 1, 0); Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); } SelectObject(hdc, hbrPrevious); DeleteObject(hbr); DeleteObject(hrgn);