自绘的listctrl控件在OnEraseBkgnd中绘制的背景图
BOOL CListCtrlCl::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值 TRACE(L"OnEraseBkgnd执行\n"); CListCtrl::OnEraseBkgnd(pDC);//擦除背景 RECT rc; GetWindowRect(&rc); CDC memDC; memDC.CreateCompatibleDC(NULL); memDC.SelectObject(&m_bgbmp); pDC->BitBlt(0,0,rc.right - rc.left,rc.bottom-rc.top,&memDC,rc.left,rc.top,SRCCOPY); return /*CListCtrl::OnEraseBkgnd(pDC)*/1;
}然后在DrawItem中根据item绘制不同的行颜色
if(lpDrawItemStruct->itemID%2)
pDC->FillSolidRect(&lpDrawItemStruct->rcItem, m_RowColor);
else
pDC->FillSolidRect(&lpDrawItemStruct->rcItem, m_RowColor1);现在背景画上去了,行颜色也改变了,但是我删除某行或者删除多行的时候,行内容不存在了,但是删除行的颜色还存在,请问如何才能把原来行的颜色也清空了呢?高手们帮帮忙吧