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