In Windows CE, a region is a rectangle that can be filled, painted, inverted, framed, and tested to see if it contains a particular point.
You create a region by calling CreateRectRgn or CreateRectRgnIndirect. These functions return a handle identifying the new region. Once you have a handle to a region, you can select the region into a device context with the SelectObject function. You can perform a variety of operations on a region: You can combine or compare it with another region, paint or invert its interior, draw a frame around it, retrieve its dimensions, and test whether or not a particular point lies within it.
Note When using the CreateRectRgn and CreateRectRgnIndirect functions, use values for regions that can be represented by 16-bit integers because that is how region data is stored in Windows CE.
The following table describes in which ways you can use the CombineRgn function to combine two regions together.
Value | Meaning |
---|---|
RGN_AND | The intersecting parts of two original regions define a new region. |
RGN_COPY | A copy of the first of the two original regions defines a new region. |
RGN_DIFF | The part of the first region that does not intersect the second defines a new region. |
RGN_OR | The two original regions define a new region. |
RGN_XOR | Those parts of the two original regions that do not overlap define a new region. |
You can use the EqualRgn function to determine whether or not two regions are equal in size and shape. You can use the FillRgn function to paint the interior of a region with a specified brush.
Windows CE does not support the InvertRgn or InvertRect functions. You can achieve the effect of InvertRect by using the PatBlt function with an ROP code of DSTINVERT.
You can retrieve the dimensions of a region's bounding rectangle by calling the GetRgnBox function. The bounding rectangle is the smallest rectangle that be drawn around a region. Use the OffsetRgn function to move a region a specified number of logical units. Use GetRegionData to retrieve data describing a region.
Note Because Windows CE represents regions differently than Windows-based desktop platforms, GetRegionData function can return a different number of rectangles for a specified region than the equivalent Windows-based desktop function.
The PtInRegion function determines if a point is inside a specified rectangle. To determine if the point is in a region, you must pass the location of the point along with a region's handle to PtInRegion.