BOOL RectVisible(hdc, lprc) | |||||
HDC hdc; | /* handle of device context | */ | |||
const RECT FAR* lprc; | /* address of structure with rectangle | */ |
The RectVisible function determines whether any part of the specified rectangle lies within the clipping region of the given device context.
hdc
Identifies the device context.
lprc
Points to a RECT structure that contains the logical coordinates of the specified 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.
The return value is nonzero if some portion of the rectangle is within the clipping region. Otherwise, it is zero.
The following example paints a clipping region yellow by painting the client area. The RectVisible function is called to determine whether a specified rectangle overlaps the clipping region. If there is some overlap, the rectangle is filled by using a red brush. If there is no overlap, text is displayed inside the clipping region. In this case, the rectangle and the region do not overlap, even though they both specify 110 as a boundary on the y-axis, because regions are defined as including the pixels up to but not including the specified right and bottom coordinates.
RECT
rc, rcVis; HRGN hrgn; HBRUSH hbrRed, hbrYellow; GetClientRect(hwnd, &rc); hrgn = CreateRectRgn(10, 10, 310, 110); SelectClipRgn(hdc, hrgn); hbrYellow = CreateSolidBrush(RGB(255, 255, 0)); FillRect(hdc, &rc, hbrYellow); SetRect(&rcVis, 10, 110, 310, 300); if (RectVisible(hdc, &rcVis)) { hbrRed = CreateSolidBrush(RGB(255, 0, 0)); FillRect(hdc, &rcVis, hbrRed); DeleteObject(hbrRed); } else { SetBkColor(hdc, RGB(255, 255, 0)); TextOut(hdc, 20, 50, "Rectangle outside clipping region.", 34); } DeleteObject(hbrYellow); DeleteObject(hrgn);