|
Outlook风格的使用不同的颜色单列显示新邮件数(3) } } 最后你需要做的只是在DrawTreeItem中自绘你想要的得效果就是了如下: void CLeftView::DrawTreeItem(int nItemState, CRect rcItem, HDC hdc, HTREEITEM hItem) { // if the item has got the focus, we have to draw sorouinding rectangle and fill a rect blue COLORREF colText = m_colText; if(nItemState & CDIS_FOCUS) { ::FillRect(hdc, &rcItem, (HBRUSH)m_BackBrush.m_hObject); // Add new focus rect code... ::DrawFocusRect( hdc, &rcItem); colText = m_colHilightText; //=:GetSysColor(COLOR_HIGHLIGHTTEXT); } else if(nItemState & CDIS_SELECTED) { ::FillRect(hdc, &rcItem, (HBRUSH)m_GrayBrush.m_hObject); } else { TRACE("CLEAR HIGH\n"); // add this to clear leftover highlight bar ::FillRect(hdc, &rcItem, (HBRUSH)m_BackBrushNormal.m_hObject); } // always write text without background ::SetBkMode(hdc, TRANSPARENT); ::SetTextColor(hdc,colText); CString str = m_pTree->GetItemText(hItem); ::DrawText(hdc, str, -1, &rcItem, DT_VCENTER DT_SINGLELINE DT_Word_ELLIPSIS); // you may modify them according to your need int nNew = 20; CString strNew = _T(""); strNew.Format(_T("(%d)"),nNew); ::SetTextColor(hdc,RGB(0,0,255)); RECT rc = rcItem; rc.left = rcItem.right+2; rc.right = rc.left + 100; ::FillRect(hdc, &rc, (HBRUSH)m_BackBrushNormal.m_hObject); ::DrawText(hdc,strNew, -1, &rc, DT_VCENTER DT_SINGLELINE DT_WORD_ELLIPSIS);
|