How do I change the treeview highlight color VB6
I haven't been able to figure out how to change the Treeview highlight text color and background color. tv1.SelectedItem.Forecolor and .BackColor does not change the Highlight colors, only changes the currently selected node color after moving to another node.
I really don't want to change the System HighLight Color, just be able to change it within my app.
Re: How do I change the treeview highlight color VB6
All solutions I've ever seen require subclassing the control & drawing the item yourself.
Re: How do I change the treeview highlight color VB6
What I ended up doing is going into the registry and retrieving the current theme highlight fore and back colors and saving them. Then allowing the user to choose the fore and back colors from the color palette and SetSysColors and saving the selections to the program's registry area, then on program exit, switch back to the theme colors. When the program is loaded I check it there is a color in the program's registry and if so, use SetSysColors.
Re: How do I change the treeview highlight color VB6
Problem with changing global system settings is that it doesn't only effect your application, it effects all applications that use those settings. Calling SetSysColors sends a message to all windows notifying them of the change & so they can repaint their windows based on the new colors. If your app crashes, then it could not reset the colors before the crash. Next time your app runs, it will read the colors you set and the previous system colors are lost until the user reboots or logs off.
Per MSDN
Quote:
It is best to respect the color settings specified by the user. If you are writing an application to enable the user to change the colors, then it is appropriate to use this function