我想在树中,点击任一节点时,该节点的背景(树中该节点所在的那一行)改变颜色,但是我不会重绘,请大家给点示例代码,谢谢,我从网上搜索了,没有找到。

解决方案 »

  1.   

    http://read.pudn.com/downloads19/sourcecode/windows/control/66601/%E6%94%B9%E5%8F%98%E6%A0%91%E6%8E%A7%E4%BB%B6%E8%83%8C%E6%99%AF%E9%A2%9C%E8%89%B2%E7%9A%84VC%E6%BA%90%E4%BB%A3%E7%A0%81/animctrl.cpp__.htm
    看看这个
      

  2.   

    HBRUSH   CDdddDlg::OnCtlColor(CDC*   pDC,   CWnd*   pWnd,   UINT   nCtlColor)    
      {  
      HBRUSH   hbr   =   CDialog::OnCtlColor(pDC,   pWnd,   nCtlColor);  
       
      if(tree.m_hWnd==pWnd->m_hWnd)  
      {  
       
      return   CreateSolidBrush(RGB(123,0,0));  
      }  
      //   TODO:   Return   a   different   brush   if   the   default   is   not   desired  
      return   hbr;  
      }   
      

  3.   

    http://www.vckbase.com/document/viewdoc/?id=355
      

  4.   


    BOOL CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
    {
    LPNMHDR pNmhdr = (LPNMHDR)lParam; switch (pNmhdr->code)
    {
    case NM_CUSTOMDRAW:
    {
    LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW)lParam;
    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;
    return true; case CDDS_ITEMPREPAINT:
    switch (pCustomDraw->iLevel)
    {
    // painting all 0-level items blue,
    // and all 1-level items red (GGH)
    case 0:
    if (pCustomDraw->nmcd.uItemState == (CDIS_FOCUS | CDIS_SELECTED)) // selected
    pCustomDraw->clrText = RGB(255, 255, 255);
    else
    pCustomDraw->clrText = RGB(0, 0, 255);
    break;
    case 1:
    if (pCustomDraw->nmcd.uItemState == (CDIS_FOCUS | CDIS_SELECTED)) // selected
    pCustomDraw->clrText = RGB(255, 255, 255);
    else
    pCustomDraw->clrText = RGB(255, 0, 0);
    break;
    } *pResult = CDRF_SKIPDEFAULT;
    return false; }
    }
    break;
    }
    return CFrameWnd::OnNotify(wParam, lParam, pResult);
    }