CBPoint FirstPt;
FirstPt = EndPt;
pDC->MoveTo((int)(FirstPt.x),(int)( FirstPt.y));
double fsin = sin(TWO_PI / iPolygonsides);
double fcos = cos(TWO_PI / iPolygonsides);
for (int i = 1 ; i < iPolygonsides ; i++)
{
CBPoint Nextpt;
Nextpt.x = (FirstPt.x - StartPt.x) * fcos - (FirstPt.y - StartPt.y) * fsin;
Nextpt.y = (FirstPt.x - StartPt.x) * fsin + (FirstPt.y - StartPt.y) * fcos;
Nextpt.x += StartPt.x;
Nextpt.y += StartPt.y;
FirstPt = Nextpt;
pDC->LineTo((int)(Nextpt.x),(int)( Nextpt.y));
}
pDC->LineTo((int)(EndPt.x),(int)( EndPt.y));