Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JFisher365 - 06 Jun 2004 00:16 GMT
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
Jeff Partch [MVP] - 06 Jun 2004 00:45 GMT
> 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;

Signature

Jeff Partch [VC++ MVP]

JFisher365 - 06 Jun 2004 01:16 GMT
   
    ----- Jeff Partch [MVP] wrote: ----
   
    "JFisher365" <anonymous@discussions.microsoft.com> wrote in messag
    news:13107F16-D999-4110-8A1B-30D3CACADEFF@microsoft.com..
    > Hello
    >> I am trying to change the color of my CTreeCtrl item text by using th
    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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.