CTreeCtrl Color/Background Color Q 
Author Message
 CTreeCtrl Color/Background Color Q

Using MFC 6.0 - how do you change color of text and background
color of INDIVIDUAL items on the tree?

I tried overriding OnDrawItem() for my CTreeCtrl but it was never
called.  Is there another way?

Even better, I'd like to do this for a CTreeView.

thanks,
brian



Mon, 10 Sep 2001 03:00:00 GMT  
 CTreeCtrl Color/Background Color Q
To change individual item color, you should implement NM_CUSTOMDRAW. This
handler is called for each item before it is drawn. At that point you can
change color,font etc.

If you want all items of the same color(which you dont), you can override
WM_CTLCOLOR.

--
Ajay Kalra

Quote:

>Using MFC 6.0 - how do you change color of text and background
>color of INDIVIDUAL items on the tree?

>I tried overriding OnDrawItem() for my CTreeCtrl but it was never
>called.  Is there another way?

>Even better, I'd like to do this for a CTreeView.

>thanks,
>brian



Mon, 10 Sep 2001 03:00:00 GMT  
 CTreeCtrl Color/Background Color Q
Thanks, I think that overriding NM_CUSTOMDRAW is the way to go, but
I'm still having a problem.

I'm overriding OnNotify and check to see if the WM_NOTIFY message
is for a NM_CUSTOMDRAW, but it never is a NM_CUSTOMDRAW msg.
If it were a NM_CUSTOMDRAW message then I'd be on my way.

I got this example from the MFC help, but can't get it to work.  Any
ideas
or a better example of how to use NM_CUSTOMDRAW?

thanks,
brian



Tue, 11 Sep 2001 03:00:00 GMT  
 CTreeCtrl Color/Background Color Q
I use the following in the message map. I use reflection for the control to
get the message instead of the parent:

 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)

and

void BRxBrowserViewControl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)

--
Ajay Kalra

Quote:

>Thanks, I think that overriding NM_CUSTOMDRAW is the way to go, but
>I'm still having a problem.

>I'm overriding OnNotify and check to see if the WM_NOTIFY message
>is for a NM_CUSTOMDRAW, but it never is a NM_CUSTOMDRAW msg.
>If it were a NM_CUSTOMDRAW message then I'd be on my way.

>I got this example from the MFC help, but can't get it to work.  Any
>ideas
>or a better example of how to use NM_CUSTOMDRAW?

>thanks,
>brian



Tue, 11 Sep 2001 03:00:00 GMT  
 CTreeCtrl Color/Background Color Q
thanks Ajay.  you were a great help.  three cheers!

brian



Fri, 14 Sep 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Win2K: static background color vs. CFormView background color

2. Background colors for CTreeCtrl

3. HELP: Background color in CTreeCtrl

4. HELP: background color in CTreeCtrl

5. HELP:CTreeCtrl background color

6. Background color in CTreeCtrl

7. How to change background color in CTreeCtrl

8. Detecting Color Pallete ( 16 colors , or 256 colors, or Hi color) URGENT

9. Background Color, Text Color

10. CEditView Background Color & Font Color :: MFC

11. Background color and text color in menu

12. Change text color and background color in CEditView

 

 
Powered by phpBB® Forum Software