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