(VS2008, MFC, feature-pack)
Using a CTreeCtrl, I need to have the selected item "better" highlighted when the control looses focus.
My Tree is created with the "TVS_SHOWSELALWAYS" option in the resource editor, but the color is not visible enough.
I already have code to change the items colors via the custom draw message (NM_CUSTOMDRAW) like this :
void MyTree::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
NMTVCUSTOMDRAW *pcd = (NMTVCUSTOMDRAW *)pNMHDR;
switch ( pcd->nmcd.dwDrawStage )
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT :
{
HTREEITEM hItem = (HTREEITEM)pcd->nmcd.dwItemSpec;
if ( this->IsSelected(hItem ))
{
pcd->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);
pcd->clrTextBk = GetSysColor(COLOR_HIGHLIGHT);
}
*pResult = CDRF_DODEFAULT;// do not set *pResult = CDRF_SKIPDEFAULT
break;
}
}
}
It's working, but is seems to be overkill for a simple task as this.
I think I must be missing something obvious to do this without having to do this.
Anything simpler ?
Thanks.