In Windows CE, a region is a rectangle that can be filled, painted, 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. 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. 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 paint or invert its interior, draw a frame around it, retrieve its dimensions, and test whether a particular point lies within it. The following table shows what tasks you can perform on regions.
To |
Call |
Determine if two regions are equal in size and shape | EqualRgn |
Paint the interior of a region with a specified brush | FillRgn |
Retrieve the dimensions of a region's bounding rectangle | GetRgnBox |
Move a region a specified number of logical units | OffsetRgn |
Retrieve data describing a region | GetRegionData |
Determine if a point is inside a specified region | PtInRegion |
You can also combine or compare a region with another region by calling the CombineRgn function. The following table shows how you can call the CombineRgn function to combine two regions together.
Value |
Description |
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. |
Windows CE does not support the InvertRgn or InvertRect functions. You can achieve the effect of InvertRect by calling the PatBlt function with an ROP code of DSTINVERT.