void CRecordItemProgressEx::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics)
{
if(!(pDrawArgs && pMetrics))
return;
// draw text
CXTPReportRecordItemText::OnDrawCaption(pDrawArgs, pMetrics);
if(!m_bUseProgress)
return;
CDC* pDC = pDrawArgs->pDC;
CXTPFontDC font(pDC);
CRect rcItem = pDrawArgs->rcItem;
CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager();
rcItem.left -= 2;
rcItem.right += 2;
rcItem.top -= 1;
rcItem.bottom += 1;
pDC->FillSolidRect(rcItem, m_bgColor);
// rcItem.bottom -= 1;
// rcItem.left += 1; // leave margin in case row is highlighted
// // draw border
// pDC->Draw3dRect(&rcItem, RGB(0,0,0), ::GetSysColor(COLOR_BTNSHADOW));
// draw progress bar and text
CRect LeftRect, RightRect;
RightRect = LeftRect = rcItem;
int w = (LeftRect.Width() * m_nProgress) / 100;
LeftRect.right = LeftRect.left + w - 1;
RightRect.left = LeftRect.right;
pDC->FillSolidRect(LeftRect, m_fgColor); // RGB(160, 32, 240)
if (m_strProgress != _T(""))
{
CString str;
str.Format(_T("%s %d%%"), m_strProgress, m_nProgress);
pDC->SetBkMode(TRANSPARENT);
CRect TextRect;
TextRect = rcItem;
TextRect.DeflateRect(1, 1);
font.SetFont(pPaintManager->GetTextFont());
CRgn rgn;
rgn.CreateRectRgn(LeftRect.left, LeftRect.top, LeftRect.right, LeftRect.bottom);
pDC->SelectClipRgn(&rgn);
pDC->SetTextColor(RGB(255, 255, 255));
pDC->DrawText(str, &TextRect, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
rgn.DeleteObject();
rgn.CreateRectRgn(RightRect.left, RightRect.top, RightRect.right, RightRect.bottom);
pDC->SelectClipRgn(&rgn);
pDC->SetTextColor(RGB(0, 0, 0));
pDC->DrawText(str, &TextRect, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
rgn.DeleteObject();
pDC->SelectClipRgn(NULL);
}
}