CRgn::CombineRgn

int CombineRgn( CRgn* pRgn1, CRgn* pRgn2, int nCombineMode );

Return Value

Specifies the type of the resulting region. It can be one of the following values:

Parameters

pRgn1

Identifies an existing region.

pRgn2

Identifies an existing region.

nCombineMode

Specifies the operation to be performed when combining the two source regions. It can be any one of the following values:

Remarks

Creates a new GDI region by combining two existing regions. The regions are combined as specified by nCombineMode.

The two specified regions are combined, and the resulting region handle is stored in the CRgn object. Thus, whatever region is stored in the CRgn object is replaced by the combined region.

The size of a region is limited to 32,767 by 32,767 logical units or 64K of memory, whichever is smaller.

Use CopyRgn to simply copy one region into another region.

Example

CRgn   rgnA, rgnB, rgnC;

VERIFY(rgnA.CreateRectRgn( 50, 50, 150, 150 ));
VERIFY(rgnB.CreateRectRgn( 100, 100, 200, 200 ));
VERIFY(rgnC.CreateRectRgn( 0, 0, 50, 50 ));

int nCombineResult = rgnC.CombineRgn( &rgnA, &rgnB, RGN_OR );
ASSERT( nCombineResult != ERROR || nCombineResult != NULLREGION );

CBrush br1, br2, br3;
VERIFY(br1.CreateSolidBrush( RGB(255, 0, 0) ));  // rgnA Red
VERIFY(pDC->FrameRgn( &rgnA, &br1, 2, 2 ));
VERIFY(br2.CreateSolidBrush( RGB(0, 255, 0) ));  // rgnB Green
VERIFY(pDC->FrameRgn( &rgnB, &br2, 2, 2 ));
VERIFY(br3.CreateSolidBrush( RGB(0, 0, 255) ));  // rgnC Blue
VERIFY(pDC->FrameRgn( &rgnC, &br3, 2, 2 ));

CRgn OverviewClass MembersHierarchy Chart

See Also   CRgn::CopyRgn, ::CombineRgn