Set Treeview Nodes to different TextColor 
Author Message
 Set Treeview Nodes to different TextColor

Hi, JG

I don't believe you can do this effectively in a pure VB environment. I
believe that C++ controls do this by drawing the visible portion directly
(owner draw) rather than using the functionality built into the treeview
control.

You will be much better off finding a 3rd party control that provides the
functionality you need.

HTH,

John Eikanger
Microsoft Visual Basic Developer Support

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2002 Microsoft Corporation.  All rights reserved.
--------------------
| Content-Class: urn:content-classes:message


| Subject: Set Treeview Nodes to different TextColor
| Date: Thu, 7 Mar 2002 07:44:28 -0800
| Lines: 10

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
| Thread-Index: AcHF7vdX7r3diaNnRxOBFkTSK2mQkA==
| Newsgroups: microsoft.public.vb.controls
| Path: cpmsftngxa09
| Xref: cpmsftngxa09 microsoft.public.vb.controls:126948
| NNTP-Posting-Host: TKMSFTNGXA14 10.201.226.42
| X-Tomcat-NG: microsoft.public.vb.controls
|
| Using VB6, trying to use more than one text color on the
| treeview nodes.  Node one is Blue, Node two is Red for
| example.  I know that this can be done using c++, and that
| the VB Treeview is a wrapper around the c++ version.  I
| can get a handle to the TreeView.Node(TV_ITEM) and I
| attempt to SendMessage a message via:
| "Call SendMessage(hItem, TVM_SETTEXTCOLOR, 0, ByVal
| clrref)"
| Anybody know if this can successfully be done?
| Thanks
|



Tue, 24 Aug 2004 04:48:43 GMT  
 Set Treeview Nodes to different TextColor
Subclass the control (maybe the parent window instead of the control) and
process NM_CUSTOMDRAW (it's a sub-message of WM_NOTIFY). In NM_CUSTOMDRAW,
lParam is a pointer to a NMTVCUSTOMDRAW-structure. This structure has a
member called nmcd, which is a structure of type NMCUSTOMDRAW.
NMTVCUSTOMDRAW.nmcd.dwDrawStage contains a CDDS_*-value:
If it's CDDS_PREPAINT, return CDRF_NOTIFYITEMDRAW. If it's
CDDS_ITEMPREPAINT, NMTVCUSTOMDRAW.clrText contains the forecolor for the
item specified in NMTVCUSTOMDRAW.nmcd.dwItemSpec and
NMTVCUSTOMDRAW.clrTextBk contains it's BackColor. Change this values,
"CopyMemory" it back to lParam and return CDRF_NEWFONT.


Mon, 23 Aug 2004 21:25:13 GMT  
 Set Treeview Nodes to different TextColor
use Node.Backcolor
ex: Node1.Backcolor=&HFFCOCO  (for blue)
     Node2.Backcolor=&HCOCOFF  (for red)
  etc:

Quote:
> Using VB6, trying to use more than one text color on the
> treeview nodes.  Node one is Blue, Node two is Red for
> example.  I know that this can be done using c++, and that
> the VB Treeview is a wrapper around the c++ version.  I
> can get a handle to the TreeView.Node(TV_ITEM) and I
> attempt to SendMessage a message via:
> "Call SendMessage(hItem, TVM_SETTEXTCOLOR, 0, ByVal
> clrref)"
> Anybody know if this can successfully be done?
> Thanks



Tue, 24 Aug 2004 23:58:52 GMT  
 Set Treeview Nodes to different TextColor
:) You never learn out! I didn't know of this. I thought you need
subclassing and customdraw and the hole stuff.


Wed, 25 Aug 2004 20:12:25 GMT  
 Set Treeview Nodes to different TextColor
Or just use Node.ForeColor/Node.BackColor. :)


Wed, 25 Aug 2004 20:12:51 GMT  
 Set Treeview Nodes to different TextColor
Likewise.

John Eikanger
Microsoft Visual Basic Developer Support

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2002 Microsoft Corporation.  All rights reserved.
--------------------




| Subject: Re: Set Treeview Nodes to different TextColor
| Date: Sat, 9 Mar 2002 13:12:25 +0100
| Lines: 4
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

| Newsgroups: microsoft.public.vb.controls
| NNTP-Posting-Host: dialin-145-254-176-028.arcor-ip.net 145.254.176.28
| Path: cpmsftngxa09!tkmsftngp01!tkmsftngp02
| Xref: cpmsftngxa09 microsoft.public.vb.controls:127070
| X-Tomcat-NG: microsoft.public.vb.controls
|
| :) You never learn out! I didn't know of this. I thought you need
| subclassing and customdraw and the hole stuff.
|
|
|



Sat, 28 Aug 2004 02:09:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Setting different tooltips for different TreeView nodes

2. TreeView : How to set a different color to node's Caption

3. TreeView : How to set a different color to node's Caption

4. TreeView : How to set a different color to node's Caption

5. TreeView : How to set a different color to node's Caption

6. TreeView : How to set a different color to node's Caption

7. Adding a node to a treeview from a different thread

8. Move Treeview Child Node To Different Parent

9. Different colors for Treeview nodes?

10. Moving Treeview Node to same level but different position

11. Change textcolor for Nodes

12. HOW TO: set color of nodes in TreeView

 

 
Powered by phpBB® Forum Software