使用 WTL 和 Graphics,我重写了一个列表视图工具,例如: ,但是在单击名称或电话号码标题进行排序后,它看起来像:。
好像旧的还在,但不是很清楚,怎么了?
核心绘制代码:
void _DrawItem(HDC hDC, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
...
CDCHandle dcx;
Gdiplus::Graphics grap(hDC);
CRect rcTmp;
GetClientRect(&rcTmp);
dcx.Attach(hDC);
BOOL bBackColor = TRUE;
if ((lpDrawItemStruct->itemID % 2) == 0)
{
bBackColor = FALSE;
}
Gdiplus::SolidBrush mySolidBrush(Gdiplus::Color(235, 235, 235,235));
if (pItem->getOver() || pItem->getChecked())
{
mySolidBrush.SetColor(Gdiplus::Color(215, 0, 0, 215));
}else{
if (bBackColor)
{
mySolidBrush.SetColor(Gdiplus::Color(235, 235, 235, 235));
}else{
mySolidBrush.SetColor(Gdiplus::Color(255, 255, 255, 255));
}
}
grap.FillRectangle(&mySolidBrush, lpDrawItemStruct->rcItem.left , lpDrawItemStruct->rcItem.top, nColumWidth,
lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top);