CDC *pDC =&MemDC;
CRect rectTab=rcWindow;
rectTab.left+=100;
rectTab.right=rectTab.left+100;
rectTab.top+=5;
rectTab.bottom=rectTab.top+25;
CList<POINT, POINT> pts;
POSITION posLeft = pts.AddHead (CPoint (rectTab.left, rectTab.top));
posLeft = pts.InsertAfter (posLeft, CPoint (rectTab.left, rectTab.top + 2));
POSITION posRight = pts.AddTail (CPoint (rectTab.right, rectTab.top));
posRight = pts.InsertBefore (posRight, CPoint (rectTab.right, rectTab.top + 2));
int xLeft = rectTab.left + 1;
int xRight = rectTab.right - 1;
int y = 0;
for (y = rectTab.top + 2; y < rectTab.bottom-4;y += 2)
{
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y));
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y+2));
posRight = pts.InsertBefore (posRight, CPoint (xRight, y));
posRight = pts.InsertBefore (posRight, CPoint (xRight, y+2));
xLeft++;
xRight--;
}
xLeft--;
xRight++;
/**/
const int nTabLeft = xLeft - 1;
const int nTabRight = xRight + 1;
for (;y < rectTab.bottom - 1; y++)
{
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft-1, y-1));
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y));
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 1, y+1));
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 2, y+2));
posRight = pts.InsertBefore (posRight, CPoint (xRight, y));
posRight = pts.InsertBefore (posRight, CPoint (xRight - 1, y + 1));
if (y == rectTab.bottom - 2)
{
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 1, y + 1));
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 3, y + 1));
posRight = pts.InsertBefore (posRight, CPoint (xRight, y + 1));
posRight = pts.InsertBefore (posRight, CPoint (xRight - 2, y + 1));
}
xLeft++;
xRight--;
}/**/
posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 2, rectTab.bottom));
posRight = pts.InsertBefore (posRight, CPoint (xRight - 2, rectTab.bottom));
LPPOINT points = new POINT [pts.GetCount ()];
int i = 0;
for (POSITION pos = pts.GetHeadPosition (); pos != NULL; i++)
{
points [i] = pts.GetNext (pos);
points [i].y = rectTab.bottom - (points [i].y - rectTab.top);
}
CRgn rgnClip;
rgnClip.CreatePolygonRgn (points, (int) pts.GetCount (), WINDING);
pDC->SelectClipRgn (&rgnClip);
//Region rg((HRGN)rgnClip.GetSafeHandle());
//CBrush br (RGB(255,255,255));
//pDC->FillRect ( rectTab,&br);
//br.DeleteObject();
/***绘制渐变色**/
int R=255;
int G=255;
int B=255;
CPen Bpen (PS_SOLID, 1, RGB(R,G,B));
CPen* pOLdBPen = pDC->SelectObject (&Bpen);
for(int i=rectTab.top;i<rectTab.bottom;i++)
{
CPen pen (PS_SOLID, 1, RGB(R--,G--,B--));
pDC->SelectObject (&pen);
pDC->MoveTo (rectTab.left,i );
pDC->LineTo (rectTab.right,i);
pen.DeleteObject();
}
Bpen.DeleteObject();
pDC->SelectObject (&pOLdBPen);
/*graphics.SetSmoothingMode(SmoothingModeHighSpeed);
SolidBrush brush22(Color(255,255, 255, 255));
graphics.FillRegion(&brush22,&rg);*/
pDC->SelectClipRgn (NULL);
CPen pen (PS_SOLID, 1, globalData.clrBarShadow);
CPen* pOLdPen = pDC->SelectObject (&pen);
for (i = 0; i < pts.GetCount (); i++)
{
if ((i % 2) != 0)
{
int x1 = points [i - 1].x;
int y1 = points [i - 1].y;
int x2 = points [i].x;
int y2 = points [i].y;
if (x1 > rectTab.CenterPoint ().x && x2 > rectTab.CenterPoint ().x)
{
x1--;
x2--;
}
if (y2 >= y1)
{
pDC->MoveTo (x1, y1);
pDC->LineTo (x2, y2);
}
else
{
pDC->MoveTo (x2, y2);
pDC->LineTo (x1, y1);
}
}
}
delete [] points;
pDC->SelectObject (pOLdPen);
rectTab.left = nTabLeft;
rectTab.right = nTabRight;
效果图: