RectInRegion

3.0

  BOOL RectInRegion(hrgn, lprc)    
  HRGN hrgn; /* handle of region, */  
  const RECT FAR* lprc; /* address of structure with rectangle */

The RectInRegion function determines whether any part of the specified rectangle is within the boundaries of the given region.

Parameters

hrgn

Identifies the region.

lprc

Points to a RECT structure containing the coordinates of the 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.

Return Value

The return value is nonzero if any part of the specified rectangle lies within the boundaries of the region. Otherwise, it is zero.

Example

The following example uses the RectInRegion function to determine whether a specified rectangle is in a region and prints the result:

HRGN hrgn;
RECT rc = { 100, 10, 130, 50 };
BOOL fRectIn;
LPSTR lpszOverlap = "Some overlap between rc and region.";
LPSTR lpszNoOverlap = "No common points in rc and region.";

fRectIn = RectInRegion(hrgn, &rc);
if (!fRectIn)
    TextOut(hdc, 10, 10, lpszNoOverlap, lstrlen(lpszNoOverlap));
else
    TextOut(hdc, 10, 10, lpszOverlap, lstrlen(lpszOverlap));

See Also

PtInRegion