MFC CRgn::CombineRgn
Hi,
I am using the following code to test the CRgn::CombineRgn function and find
that I am unable to successfully combine the regions. Am I doing something
wrong or have I just run out of memory allocation ? How are regions of this
size selected ?
The mapping mode used in this application is MM_LOENGLISH
void CSimconDoc::OnTestrgn()
{
CRgn rgn1, rgn2, rgn3;
CPoint *pPoint = (CPoint*)new BYTE[4*sizeof(CPoint)];
pPoint[0] = CPoint(0, 0);
pPoint[1] = CPoint(1000, -590);
pPoint[2] = CPoint(1000, -610);
pPoint[3] = CPoint(0, -10);
CPoint *pPoints = (CPoint*)new BYTE[4*sizeof(CPoint)];
pPoints[0] = CPoint(100, -590);
pPoints[1] = CPoint(1000, -590);
pPoints[2] = CPoint(1000, -610);
pPoints[3] = CPoint(100, -610);
if(!rgn1.CreatePolygonRgn(pPoint, 4, WINDING))
TRACE("Unable to create polygon region\n");
else
TRACE("Polygon region 1 created\n");
if(!rgn2.CreatePolygonRgn(pPoints, 4, WINDING))
TRACE("Unable to create polygon region\n");
else
TRACE("Polygon region 2 created\n");
if(!rgn3.CreatePolygonRgn(pPoints, 4, WINDING))
TRACE("Unable to create polygon region\n");
else
TRACE("Polygon region 3 created\n");
???? if(rgn3.CombineRgn(&rgn1, &rgn2, RGN_OR) == ERROR) ????
TRACE("Unable to combine rgn1 and rgn2\n");
else
TRACE("Rgn1 and rgn2 combined successfully\n");
delete pPoint;
delete pPoints;
}
Hope you can help.
Best Regards,
Ian