Hello,
I've been updating an MFC app and have encountered custom draw or paint issues with a ctreectrl in windows 8 where it paints correctly on Win xp and a win 7 machine. I have managed to knock up a simple app using the VS2010 wizard and replicated this issue.
The test app just changes background color of the item. This is a simplified version of the custom draw that we're using in our app and has the same paint stages too. This code just changes the background color for each item.
... ON_NOTIFY(NM_CUSTOMDRAW, IDC_TREE1, &CMyTreeView::OnNMCustomdrawTree1) ... void CMyTreeView::OnNMCustomdrawTree1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR); // Recast for color change LPNMTVCUSTOMDRAW tvcd = (LPNMTVCUSTOMDRAW) pNMHDR; // Get the tree control item HTREEITEM hItem = (HTREEITEM) (pNMCD->dwItemSpec); *pResult = CDRF_DODEFAULT; if(hItem == NULL) { return; } switch(tvcd->nmcd.dwDrawStage) { case CDDS_PREPAINT: *pResult = (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW); break; case CDDS_ITEMPREPAINT: {// Set Item background color if ((tvcd->nmcd.uItemState & CDIS_SELECTED) == CDIS_SELECTED) {// Set item text to bold if selected m_TreeCtrl.SetItemState(hItem,TVIS_BOLD,TVIS_BOLD); } else m_TreeCtrl.SetItemState(hItem,0,TVIS_BOLD); tvcd->clrTextBk = Items.GetAt((POSITION)(m_TreeCtrl.GetItemData(hItem))).col; *pResult = (CDRF_NOTIFYPOSTPAINT); break; } case CDDS_ITEMPOSTPAINT: {// Draw additional information next to item *pResult = CDRF_DODEFAULT; break; } } } Any thoughts or ideas would be welcome.