正文

Custom Draw ListView Controls(3)2009-01-20 11:40:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/yuqiexing/40620.html

分享到:

 case CDDS_ITEMPREPAINT|CDDS_SUBITEM:

  {

   // Sub Item PrePaint

   // set sub item number (data will be valid now)

   int nSubItem = pNMLVCUSTOMDRAW->iSubItem;

 

   m_pOldSubItemFont = NULL;

 

   bNotifyPostPaint =

    IsNotifySubItemPostPaint(nItem, nSubItem, nState, lParam);

 

   // set up the colors to use

   pNMLVCUSTOMDRAW->clrText =

    TextColorForSubItem(nItem,nSubItem,nState,lParam);

 

   pNMLVCUSTOMDRAW->clrTextBk =

    BkColorForSubItem(nItem,nSubItem,nState,lParam);

 

   // set up a different font to use, if any

   CFont* pNewFont =

    FontForSubItem(nItem, nSubItem, nState, lParam);

 

   if (pNewFont) {

    if (! pDC) pDC = CDC::FromHandle(hdc);

     m_pOldSubItemFont = pDC->SelectObject(pNewFont);

 

     bNotifyPostPaint = true;    // need to restore font

    }

 

    // do we want to draw the item ourselves?

    if (IsSubItemDraw(nItem,nSubItem,nState,lParam)) {

     if (! pDC) pDC = CDC::FromHandle(hdc);

      if (OnSubItemDraw(pDC,nItem,nSubItem,nState,lParam)) {

 

     // we drew it all ourselves

     // so don't do default

     bSkipDefault = true;

    }

   }

  }

  break;

 

  case CDDS_ITEMPOSTPAINT|CDDS_SUBITEM:

  {

   // Sub Item PostPaint

   // set sub item number (data will be valid now)

   int nSubItem = pNMLVCUSTOMDRAW->iSubItem;

 

   // restore old font if any

   if (m_pOldSubItemFont) {

    if (! pDC) pDC = CDC::FromHandle(hdc);

     pDC->SelectObject(m_pOldSubItemFont);

 

    m_pOldSubItemFont = NULL;

   }

 

   // do we want to do any extra drawing?

   if (IsSubItemPostDraw()) {

    if (! pDC) pDC = CDC::FromHandle(hdc);

    OnSubItemPostDraw(pDC,nItem,nSubItem,nState,lParam);

   }

  }

  break;

 

阅读(1665) | 评论(1)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册