Results 1 to 4 of 4

Thread: How do I change the treeview highlight color VB6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    Question 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.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,482

    Re: How do I change the treeview highlight color VB6

    All solutions I've ever seen require subclassing the control & drawing the item yourself.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    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.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,482

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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
  •  



Click Here to Expand Forum to Full Width