|
tree控件失去焦点依然保持高亮
void CTreeCtrlExt::OnNMCustomdrawTree(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
*pResult = 0;
LPNMTVCUSTOMDRAW pDraw=(LPNMTVCUSTOMDRAW)pNMHDR;
DWORD dwDrawStage=pDraw->nmcd.dwDrawStage;
UINT uItemState =pDraw->nmcd.uItemState;
*pResult=CDRF_NOTIFYITEMDRAW;
CDC* pdc=CDC::FromHandle(pDraw->nmcd.hdc);
CRect rc;
HTREEITEM hItem=(HTREEITEM) pDraw->nmcd.dwItemSpec;
GetItemRect(hItem,&rc,TRUE);//FALSE);text only
CString txt=GetItemText(hItem);
if((dwDrawStage & CDDS_ITEM) && (uItemState & CDIS_SELECTED))
{
pDraw->clrTextBk = GetSysColor(COLOR_HIGHLIGHT);
pDraw->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);
*pResult |= CDRF_DODEFAULT;
}
else // without these ,1st blue !
{
pdc->FillSolidRect(&rc, GetSysColor(COLOR_WINDOW));
pdc->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
pdc->TextOut(rc.left+2, rc.top+2, txt);
}
} |
|