Can't Get Individual Items To Change Color in a CTreeCtrl

G

Guest

Hello

I am trying to change the color of my CTreeCtrl item text by using the Custom Draw event handler. While I see the correct progression of messages while debugging, I never see the color of the text change. I have included my event handler code...can anyone see a problem? Is there some setting in the resource file that I have to tweak

void CCallLibraryView::OnNMCustomdrawTree1(NMHDR *pNMHDR, LRESULT *pResult

LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR)

switch (pNMCD->dwDrawStage

case CDDS_PREPAINT

*pResult = CDRF_NOTIFYITEMDRAW
break


case CDDS_ITEMPREPAINT

LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW) pNMCD->lItemlParam
pCustomDraw->clrText = RGB(255,0,0)
*pResult = CDRF_NEWFONT
break


default

*pResult = CDRF_DODEFAULT
break




Thanks In Advance
John
 
J

Jeff Partch [MVP]

JFisher365 said:
Hello,

I am trying to change the color of my CTreeCtrl item text by using the
Custom Draw event handler. While I see the correct progression of messages
while debugging, I never see the color of the text change. I have included
my event handler code...can anyone see a problem?

I think it's this line...
LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW) pNMCD->lItemlParam;

....should that maybe be...

LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW) pNMCD;
 
G

Guest

----- Jeff Partch [MVP] wrote: ----

JFisher365 said:
Custom Draw event handler. While I see the correct progression of message
while debugging, I never see the color of the text change. I have include
my event handler code...can anyone see a problem

I think it's this line..
LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW) pNMCD->lItemlParam

....should that maybe be..

LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW) pNMCD

--
Jeff Partch [VC++ MVP

That was it. I got confused by the documentation. I wonder why the Add Event Handler wizard would add in it's own code as LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR) instead of the Tree Control specific version. I had looked thru some OnNotify code and it set the LPNMTVCUSTOMDRAW pCustomDraw pointer to the lParam argument. I guess I had assumed that it meant the lItemlParam field of the original pointer

Anyway, thank you for the quick response and great information!!

Joh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top