Compartir a través de


CRgn::CreateEllipticRgn

Creates an elliptical region.

BOOL CreateEllipticRgn(
   int x1,
   int y1,
   int x2,
   int y2 
);

Parameters

  • x1
    Specifies the logical x-coordinate of the upper-left corner of the bounding rectangle of the ellipse.

  • y1
    Specifies the logical y-coordinate of the upper-left corner of the bounding rectangle of the ellipse.

  • x2
    Specifies the logical x-coordinate of the lower-right corner of the bounding rectangle of the ellipse.

  • y2
    Specifies the logical y-coordinate of the lower-right corner of the bounding rectangle of the ellipse.

Return Value

Nonzero if the operation succeeded; otherwise 0.

Remarks

The region is defined by the bounding rectangle specified by x1, y1, x2, and y2. The region is stored in the CRgn object.

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

When it has finished using a region created with the CreateEllipticRgn function, an application should select the region out of the device context and use the DeleteObject function to remove it.

Example

CRgn   rgnA, rgnB, rgnC;

VERIFY(rgnA.CreateEllipticRgn(200, 100, 350, 250));
VERIFY(rgnB.CreateRectRgn( 0, 0, 50, 50 ));
VERIFY(rgnB.CopyRgn( &rgnA ));
int nOffsetResult = rgnB.OffsetRgn( -75, 75 );
ASSERT( nOffsetResult != ERROR && nOffsetResult != NULLREGION );

VERIFY(rgnC.CreateRectRgn( 0, 0, 1, 1));
int nCombineResult = rgnC.CombineRgn( &rgnA, &rgnB, RGN_AND );
ASSERT( nCombineResult != ERROR && nOffsetResult != NULLREGION );

CBrush brA, brB, brC;
VERIFY(brC.CreateHatchBrush( HS_FDIAGONAL, RGB(0, 0, 255) )); // Blue
VERIFY(pDC->FillRgn( &rgnC, &brC ));
VERIFY(brA.CreateSolidBrush( RGB(255, 0, 0) ));  // rgnA Red
VERIFY(pDC->FrameRgn( &rgnA, &brA, 2, 2 ));
VERIFY(brB.CreateSolidBrush( RGB(0, 255, 0) ));  // rgnB Green
VERIFY(pDC->FrameRgn( &rgnB, &brB, 2, 2 ));   

Requirements

Header: afxwin.h

See Also

Reference

CRgn Class

Hierarchy Chart

CRgn::CreateEllipticRgnIndirect

CreateEllipticRgn

Other Resources

CRgn Members