15,979
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
int Heigh= rect.Height();
rect.top += (Heigh/3);
rect.bottom -= (Heigh/3);
//rect.bottom -= 1;
rect.left += 1; // leave margin in case row is highlighted
rect.right -= 2;
// draw border
//绘制矩形框
CPen graypen(PS_SOLID, 1, m_crBtnShadow);
CPen *pOldPen = pDC->SelectObject(&graypen);
pDC->MoveTo(rect.left, rect.bottom);
pDC->LineTo(rect.right+1, rect.bottom);
pDC->MoveTo(rect.left, rect.top);
pDC->LineTo(rect.right+1, rect.top);
pDC->MoveTo(rect.left, rect.top);
pDC->LineTo(rect.left, rect.bottom);
pDC->MoveTo(rect.right, rect.top);
pDC->LineTo(rect.right, rect.bottom);
// fill interior with light gray
CRect InteriorRect;
InteriorRect = rect;
InteriorRect.left += 1;
InteriorRect.top += 1;
pDC->FillSolidRect(InteriorRect, RGB(224,224,224));
// finish drawing border
//绘制阴影
CPen blackpen(PS_SOLID, 1, RGB(0,0,0));
pDC->SelectObject(&blackpen);
pDC->MoveTo(rect.left+1, rect.top+1);
pDC->LineTo(rect.right, rect.top+1);
pDC->MoveTo(rect.left+1, rect.top+1);
pDC->LineTo(rect.left+1, rect.bottom);
pDC->SelectObject(pOldPen);
if (pXLCD[nSubItem].nProgressPercent > 0)
{
// draw progress bar and text
CRect LeftRect, RightRect;
LeftRect = rect;
LeftRect.left += 2;
LeftRect.top += 2;
RightRect = LeftRect;
int w = (LeftRect.Width() * pXLCD[nSubItem].nProgressPercent) / 100;
LeftRect.right = LeftRect.left + w;
RightRect.left = LeftRect.right + 1;
// 更改进度条颜色
COLORREF color=RGB(0,255,0);
pDC->FillSolidRect(LeftRect, color);
//pDC->FillSolidRect(LeftRect, m_crHighLight);
if (pXLCD[nSubItem].bShowProgressMessage)
{
CString str, format;
format = pXLCD[nSubItem].strProgressMessage;
if (format.IsEmpty())
str.Format(_T("%d%%"), pXLCD[nSubItem].nProgressPercent);
else
str.Format(format, pXLCD[nSubItem].nProgressPercent);
pDC->SetBkMode(TRANSPARENT);
CRect TextRect;
TextRect = rect;
TextRect.DeflateRect(1, 1);
TextRect.top += 1;
CRgn rgn;
rgn.CreateRectRgn(LeftRect.left, LeftRect.top, LeftRect.right, LeftRect.bottom);
pDC->SelectClipRgn(&rgn);
pDC->SetTextColor(crBkgnd);
pDC->DrawText(str, &TextRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
rgn.DeleteObject();
rgn.CreateRectRgn(RightRect.left, RightRect.top, RightRect.right, RightRect.bottom);
pDC->SelectClipRgn(&rgn);
pDC->SetTextColor(crText);
pDC->DrawText(str, &TextRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
rgn.DeleteObject();
pDC->SelectClipRgn(NULL);
}
}