|
Outlook风格的使用不同的颜色单列显示新邮件数(2) { static CRect rcItem; static int nItemState; LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW)pNmhdr; switch (pCustomDraw->nmcd.dwDrawStage) { case CDDS_PREPAINT: // Need to process this case and set pResult to CDRF_NOTIFYITEMDRAW, // otherwise parent will never receive CDDS_ITEMPREPAINT notification. (GGH) *pResult = CDRF_NOTIFYITEMDRAW; // reposuition the viewport so the TreeCtrl DefWindowProc doesn't draw to viewport 0/0 //::SetViewportOrgEx(pCustomDraw->nmcd.hdc, /*m_nOffset*/0, 0, NULL); break; case CDDS_ITEMPREPAINT: // set the background and foregroundcolor of the item to the background, so you don't see the default drawing of the text //get item state(focus,selected..), because it will be drawn of us nItemState = pCustomDraw->nmcd.uItemState; pCustomDraw->nmcd.uItemState &= ~CDIS_FOCUS; pCustomDraw->clrText = m_colHilightText; // remember the drawing rectangle of the item so we can draw it ourselves m_pTree->GetItemRect((HTREEITEM) pCustomDraw->nmcd.dwItemSpec, &rcItem, TRUE); *pResult = CDRF_NOTIFYPOSTPAINT; break; case CDDS_ITEMPOSTPAINT: DrawTreeItem(nItemState, rcItem, pCustomDraw->nmcd.hdc, (HTREEITEM) pCustomDraw->nmcd.dwItemSpec); break; default: *pResult = CDRF_DODEFAULT;
|