关于从 CRgn 对象中提取点的查询

Query regarding extracting points from a CRgn Object

我用 CRgn::CreatePolygonRgn() 创建了一个 CRgn。现在我需要从该区域提取这些点。我发现可以使用 CRgn::GetRegionData() 提取数据。但无法获取数据的..

谁能举个例子告诉我..

能够使用 OnPaint 事件检索有效数据。

CPaintDC dc(this); // device context for painting       

CRgn   rgnA;

CPoint ptVertex[5];

ptVertex[0].x = 180;
ptVertex[0].y = 80;
ptVertex[1].x = 100;
ptVertex[1].y = 160;
ptVertex[2].x = 120;
ptVertex[2].y = 260;
ptVertex[3].x = 240;
ptVertex[3].y = 260;
ptVertex[4].x = 260;
ptVertex[4].y = 160;

VERIFY(rgnA.CreatePolygonRgn(ptVertex, 5, ALTERNATE));

CRect rectRgnBox;
int nRgnBoxResult = rgnA.GetRgnBox(&rectRgnBox);
ASSERT(nRgnBoxResult != ERROR && nRgnBoxResult != NULLREGION);

CBrush brA;
VERIFY(brA.CreateSolidBrush(RGB(255, 0, 0)));  // rgnA Red
VERIFY(dc.FrameRgn(&rgnA, &brA, 2, 2));
rectRgnBox.InflateRect(3, 3);

int size = GetRegionData(rgnA, 0, NULL);
int rectcount = 0;

if (size)
{
    RGNDATA * pRegion = (RGNDATA *) new char[size];
    GetRegionData(rgnA, size, pRegion);

    RECT * pRect = (RECT *)& pRegion->Buffer;

    int rectcount = pRegion->rdh.nCount;

    if (pRegion)
    {
        int f;
        for (unsigned i = 0; i < pRegion->rdh.nCount; i++)
        {
            f = pRect[i].left;
            f = pRect[i].top;
            f = pRect[i].right;
            f = pRect[i].bottom;
        }                   
    }

    delete[](char *) pRegion;

}

代码参考 CRgn::CreatePolygonRgn

编辑

每个具有独特颜色的矩形将说明矩形如何填充区域