Change text color of selected item in a tree control
-
My requirement is If i select an item in a tree Control that Selected item's color of text should be changed.(or i want to recognize whether it is selected or not--some way to identify)So can you please tell me how to do it. bhw
-
My requirement is If i select an item in a tree Control that Selected item's color of text should be changed.(or i want to recognize whether it is selected or not--some way to identify)So can you please tell me how to do it. bhw
-
My requirement is If i select an item in a tree Control that Selected item's color of text should be changed.(or i want to recognize whether it is selected or not--some way to identify)So can you please tell me how to do it. bhw
Handle the NM_CUTOME draw message and put the following code inside it. void TreeCtrlEx::OnCustomDraw( NMHDR* pNMHDR_i, LRESULT* pResult_o ) { NMTVCUSTOMDRAW* pLVCD = reinterpret_cast( pNMHDR_i ); NMCUSTOMDRAW &nMcd = pLVCD->nmcd; *pResult_o = CDRF_DODEFAULT; switch( nMcd.dwDrawStage ) { case CDDS_PREPAINT: // Item prepaint notification. *pResult_o = CDRF_NOTIFYITEMDRAW; break; case CDDS_ITEMPREPAINT: { // Set the color of the text according to its state. HTREEITEM nRow = reinterpret_cast< HTREEITEM >( nMcd.dwItemSpec ); if( CDIS_SELECTED == ( nMcd.uItemState & CDIS_SELECTED )) { pLVCD->clrText = clrSelText;// Selected text color pLVCD->clrTextBk = clrSelBk;// Selceted backgroung } else { pLVCD->clrText = clrNormal;// text color in normal state pLVCD->clrTextBk = clrBk// bakck ground color in normal state } // Allow it to do the default painting. *pResult_o = CDRF_DODEFAULT; break; } default: *pResult_o = CDRF_DODEFAULT; break; } }
nave [OpenedFileFinder]