Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

how to eliminate extra focus rectangles using CDRF_SKIPPOSTPAINT in customdrawing CTreeCtrl

$
0
0

I want to eliminate these:

My customdraw code is this:

  void MyCTreeCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
    {
      LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
      HTREEITEM hti;
      switch (pNMCD->dwDrawStage)
      {
      case CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW;
        itemDC = CDC::FromHandle(pNMCD->hdc);
        break;

      case CDDS_ITEMPREPAINT: // first NM_CUSTOMDRAW notification
        hti = (HTREEITEM)pNMCD->dwItemSpec/*htreeitem*/;

        ... // draw some buttons and symbols

        // As msdn says, let the context determine when events need to occur, so check for last cxnode and then do post paint handler.
        if (cxNode->IsLastNodeInTree())
        {
          *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT | CDRF_SKIPPOSTPAINT; // notify subitems that they need to be painted as well and then notify post paint
        }
        else
        {
          *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_SKIPPOSTPAINT; // notify subitems that they need to be painted as well
        }
        break;

      case CDDS_ITEMPOSTPAINT:
        *pResult = CDRF_SKIPDEFAULT; // don't do any drawing after this (not sure this works)
        break;

      case CDDS_POSTPAINT:
        *pResult = CDRF_SKIPDEFAULT; // don't do any drawing after this (not sure this works)
        break;
      }
    }

The documentation says that by using CDRF_SKIPPOSTPAINT that "The control will not draw the focus rectangle". The code runs fine, but just doesn't do anything with the annoying focus rectangles.

Anyone have experience with this?


RT



Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>