Does anyone have a project or link demonstrating padding and selection color for the TreeView control?
I have just produced a program that demonstrates how to colour the individual labels of a TreeView control (attached).
This program demonstrates how to set the background colour and the text colour of the labels in a TreeView control for both when a node is selected and when a node is not selected.
Right-click on a node and select an option from the context menu to change the colour of the label for that node. When you click on another label the chosen colours will be applied.
The colours are stored in a structure associated with the lParam member of the TV_ITEM structure of a TreeView control. When an option is selected from the context menu, a notification message is sent to the TreeView control's parent window containing the code NM_CUSTOMDRAW. The program responds to this code to colour the nodes of the tree.
When the program terminates, the memory used to store the data in the lParam member of the TV_ITEM structure for each node must be freed by calling the recursive function FreeLParam.
Although a global handle for the TreeView control is declared, the functions in this program have an argument for the handle of the TreeView control. This is because these functions form part of a TreeView library I am developing and I will publish the library in this forum when I have completed it.
Each function contains a brief description of its purpose.