CombineRgn function (wingdi.h)

The CombineRgn function combines two regions and stores the result in a third region. The two regions are combined according to the specified mode.

Syntax

int CombineRgn(
  [in] HRGN hrgnDst,
  [in] HRGN hrgnSrc1,
  [in] HRGN hrgnSrc2,
  [in] int  iMode
);

Parameters

[in] hrgnDst

A handle to a new region with dimensions defined by combining two other regions. (This region must exist before CombineRgn is called.)

[in] hrgnSrc1

A handle to the first of two regions to be combined.

[in] hrgnSrc2

A handle to the second of two regions to be combined.

[in] iMode

A mode indicating how the two regions will be combined. This parameter can be one of the following values.

Value Meaning
RGN_AND
Creates the intersection of the two combined regions.
RGN_COPY
Creates a copy of the region identified by hrgnSrc1.
RGN_DIFF
Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
RGN_OR
Creates the union of two combined regions.
RGN_XOR
Creates the union of two combined regions except for any overlapping areas.

Return value

The return value specifies the type of the resulting region. It can be one of the following values.

Return code Description
NULLREGION
The region is empty.
SIMPLEREGION
The region is a single rectangle.
COMPLEXREGION
The region is more than a single rectangle.
ERROR
No region is created.

Remarks

The three regions need not be distinct. For example, the hrgnSrc1 parameter can equal the hrgnDest parameter.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See also

CreateEllipticRgn

CreateEllipticRgnIndirect

CreatePolyPolygonRgn

CreatePolygonRgn

CreateRectRgn

CreateRectRgnIndirect

CreateRoundRectRgn

Region Functions

Regions Overview