Support for
GDI regions is provided in MFC through the
CRgn class. A
region is created by first creating the CRgn object, and
then calling an initialization function.
There are a
large number of CRgn initialization functions. These are
summarized in Table 2.
|
|
CreateRectRgn
|
A
rectangular region
|
CreateRectRgnIndirect
|
A
region from a RECT structure
|
CreateEllipticRgn
|
An
elliptical region
|
CreateEllipticRgnIndirect
|
An
elliptical region from a RECT structure
|
CreatePolygonRgn
|
A
polygonal region
|
CreatePolyPolygonRgn
|
A
region of several (possibly disjoint) polygons
|
CreateRoundRectRgn
|
A
region in the shape of a rounded rectangle
|
CombineRgn
|
A
region that is the union of two existing regions
|
CopyRgn
|
A
region that is the copy of another region
|
CreateFromPath
|
A
region from a path
|
CreateFromData
|
A
region from a RGNDATA structure and an XFORM
matrix
|
To compare
two CRgn objects and check if they are equivalent, use the
EqualRgn member function. To obtain a RGNDATA structure
for a CRgn object, call GetRegionData. To obtain a
region's bounding rectangle (that is, the tightest
rectangle that encloses the region), call GetRgnBox.
To set a
region to a specific rectangle, call SetRectRgn. To move a
region by a specific offset, use OffsetRgn.
You can
determine whether a given point or parts of a given
rectangle fall within the region; use the PtInRegion or
RectInRegion member functions.
A CRgn
object can be used in place of an HRGN handle in
GDI
function calls, thanks to the presence of the operator
function operator HRGN.
MFC
Example
Note:
UCanCode Advance E-XD++
CAD Drawing and Printing Solution
Source Code Solution for C/C++, .NET V2024 is released!
Contact UCanCode Software
To buy the source code or learn more about with: