-
Feb 9th, 2015, 09:25 AM
#1
Thread Starter
Addicted Member
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.
-
Feb 9th, 2015, 10:53 AM
#2
Re: How do I change the treeview highlight color VB6
All solutions I've ever seen require subclassing the control & drawing the item yourself.
-
Mar 2nd, 2015, 06:10 PM
#3
Thread Starter
Addicted Member
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.
-
Mar 3rd, 2015, 09:25 AM
#4
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
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|