afx_msg void OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult);
ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, &C_CodeList::OnNMCustomdrawList1)
void C_CodeList::OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
// TODO: Add your control notification handler code here
LPNMLVCUSTOMDRAW pnmCustDraw = (LPNMLVCUSTOMDRAW)pNMHDR;
TRACEINFO(L"OnNMCustomdrawList1");
switch(pnmCustDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW ;
break;
case CDDS_ITEMPREPAINT:
{
COLORREF clrCodeInvalidColor;
clrCodeInvalidColor = RGB(0xff, 0x00, 0x00);
int nItem = static_cast<int>( pnmCustDraw->nmcd.dwItemSpec );
int nSubItem=pnmCustDraw->iSubItem;
if(m_pCurDocument != NULL)
{
IGPBCPage * pCurPage = m_pCurDocument->GetSelectPage();
if(pCurPage != NULL)
{
IGPBCShape * pShape = pCurPage->GetShapeAt(nItem);
if(pShape != NULL)
{
if(!pShape->IsCodeValid())
pnmCustDraw->clrTextBk = clrCodeInvalidColor;
}
}
}
break;
}
case CDDS_SUBITEM:
{
COLORREF clrCodeInvalidColor;
clrCodeInvalidColor = RGB(0xff, 0x00, 0x00);
int nItem = static_cast<int>( pnmCustDraw->nmcd.dwItemSpec );
int nSubItem=pnmCustDraw->iSubItem;
if(m_pCurDocument != NULL)
{
IGPBCPage * pCurPage = m_pCurDocument->GetSelectPage();
if(pCurPage != NULL)
{
IGPBCShape * pShape = pCurPage->GetShapeAt(nItem);
if(pShape != NULL)
{
if(!pShape->IsCodeValid())
pnmCustDraw->clrTextBk = clrCodeInvalidColor;
}
}
}
break;
}
case CDDS_ITEMPOSTPAINT:
{
TRACEINFO(L"CDDS_ITEMPOSTPAINT");
int iItem = pnmCustDraw->nmcd.dwItemSpec;
CDC dc;
dc.Attach(pnmCustDraw->nmcd.hdc);
CRect rectDest;
m_lcCodeList.GetItemRect(iItem,rectDest,LVIR_ICON);
dc.DPtoLP(rectDest);
CBrush brush(0xffff0000);
dc.FillRect(&rectDest, &brush);
dc.Detach();
*pResult = CDRF_DODEFAULT;
break;
}
default:
*pResult = CDRF_DODEFAULT;
break;
}
return ;
}