void CListCtrlEx::DrawProgress(CDC *pDC, CString &strText, CRect &rcCell, BOOL bSelected, const CellData &cellData)
{
CRect rcFill(rcProg);
rcFill.DeflateRect(1,1,1,1);
float fPersent=0.0f;
int nFill=GetProgBarSize(cellData, rcProg, &fPersent);
rcFill.right=min(rcFill.left+nFill, rcFill.right);
int n = rcFill.right - rcFill.left;
int m = rcFill.left;
CDC mdc;
mdc.CreateCompatibleDC(pDC);创建一个与指定设备兼容的内存 设备上下文环境(DC)。
CBitmap bmp;
bmp.CreateCompatibleBitmap(pDC,rcCell.Width()+rcCell.left,rcCell.Height()+rcCell.top); // 创建新的位图资源,注意长宽
mdc.SelectObject(&bmp);
mdc.FillSolidRect(rcCell,RGB(255,255,255));
//CBrush brush1(RGB(255,255,255));
if(m_currentWnd!=-1)
{
if(cellData.m_bglst.empty())
{
rcFill.right = rcFill.left;
mdc.FillSolidRect(rcCell,RGB(255,255,255));
}
else
{
for(auto it = cellData.m_bglst.begin(); it != cellData.m_bglst.end(); it++)
{
if((*it).startPos>=0&&(*it).startPos<=1)
{
rcFill.left = n*(*it).startPos+m;
rcFill.right = n *(*it).endPos+m;
mdc.FillSolidRect(rcFill,crProgFill);
}
}
}
if(C_Pos[m_currentWnd]>0)
{
CBrush brush(RGB(255,0,0));
mdc.SelectObject(brush);
mdc.Ellipse(m + C_Pos[m_currentWnd]*n+3,(rcFill.bottom+rcFill.top)/2+3,m + C_Pos[m_currentWnd]*n-3,(rcFill.bottom+rcFill.top)/2-3);
}
}
CPen pen1(PS_SOLID,1,RGB(255,0,0));
mdc.SelectObject(pen1);
mdc.MoveTo(482,1);
mdc.LineTo(482,101);
pDC->BitBlt(rcCell.left,rcCell.top,rcCell.Width(),rcCell.Height(),&mdc,rcCell.left,rcCell.top,SRCCOPY);//拷贝DC
bmp.DeleteObject();//释放位图
mdc.DeleteDC();//释放DC
}