case CDDS_ITEMPREPAINT|CDDS_SUBITEM:
{
// Sub Item PrePaint
// set sub item number (data will be valid now)
int nSubItem = pNMLVCUSTOMDRAW->iSubItem;
m_pOldSubItemFont = NULL;
bNotifyPostPaint =
IsNotifySubItemPostPaint(nItem, nSubItem, nState, lParam);
// set up the colors to use
pNMLVCUSTOMDRAW->clrText =
TextColorForSubItem(nItem,nSubItem,nState,lParam);
pNMLVCUSTOMDRAW->clrTextBk =
BkColorForSubItem(nItem,nSubItem,nState,lParam);
// set up a different font to use, if any
CFont* pNewFont =
FontForSubItem(nItem, nSubItem, nState, lParam);
if (pNewFont) {
if (! pDC) pDC = CDC::FromHandle(hdc);
m_pOldSubItemFont = pDC->SelectObject(pNewFont);
bNotifyPostPaint = true; // need to restore font
}
// do we want to draw the item ourselves?
if (IsSubItemDraw(nItem,nSubItem,nState,lParam)) {
if (! pDC) pDC = CDC::FromHandle(hdc);
if (OnSubItemDraw(pDC,nItem,nSubItem,nState,lParam)) {
// we drew it all ourselves
// so don't do default
bSkipDefault = true;
}
}
}
break;
case CDDS_ITEMPOSTPAINT|CDDS_SUBITEM:
{
// Sub Item PostPaint
// set sub item number (data will be valid now)
int nSubItem = pNMLVCUSTOMDRAW->iSubItem;
// restore old font if any
if (m_pOldSubItemFont) {
if (! pDC) pDC = CDC::FromHandle(hdc);
pDC->SelectObject(m_pOldSubItemFont);
m_pOldSubItemFont = NULL;
}
// do we want to do any extra drawing?
if (IsSubItemPostDraw()) {
if (! pDC) pDC = CDC::FromHandle(hdc);
OnSubItemPostDraw(pDC,nItem,nSubItem,nState,lParam);
}
}
break;
评论