Sign in to follow this  
Followers 0
SkellySoul

Tree View Color

3 posts in this topic

#1 ·  Posted (edited)

Hi, I need help with setting color to a tree view in my GUI, like this ;)

+ Vegetables

-- Pea's

-- Carrots

+ Fruit

--- Apples

--- Oranges

This code works for me

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>

GUICreate("Test")
$Tree = GUICtrlCreateTreeView(0, 0, 100, 200)
GUICtrlCreateTreeViewItem("A", $Tree)
GUICtrlCreateTreeViewItem("B", $Tree)
GUICtrlSetColor(-1 , 0x0000C0)
GUICtrlCreateTreeViewItem("C", $Tree)
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

However this code does not

#include <WinAPI.au3>
#include <GUIListView.au3>
#include <GUITreeView.au3>
#include <GUIImageList.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
$Width = 800
$Height = 500

$Form1 = GUICreate("Test", $Width, $Height)
$TreeView1 = GUICtrlCreateTreeView(0, 0, 200, 300)

$hImage = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($hImage, @ScriptDir & "\Type_1.ico")
_GUIImageList_AddIcon($hImage, @ScriptDir & "\Type_2.ico")
_GUIImageList_AddIcon($hImage, @ScriptDir & "\Type_3.ico")
_GUIImageList_AddIcon($hImage, @ScriptDir & "\Find.ico")
_GUICtrlTreeView_SetNormalImageList($TreeView1, $hImage)

_GUICtrlTreeView_BeginUpdate($TreeView1)
$Option_1 = _GUICtrlTreeView_Add($TreeView1, 0, "Option 1", 0, 0)
GUICtrlSetColor(-1 , 0x0000C0)
_GUICtrlTreeView_Add($TreeView1, 0, "Option 2", 1, 1)
_GUICtrlTreeView_Add($TreeView1, 0, "Option 3", 2, 2)
_GUICtrlTreeView_AddChild($TreeView1, $Option_1, "Test", 3, 3)
_GUICtrlTreeView_EndUpdate($TreeView1)

GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

And the problem is I have to use _GUICtrlTreeView_Add and _GUICtrlTreeView_AddChild in order to set images but cannot change their colors :huh2:

Thanks :alien:

Edited by SkellySoul

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Change part of this code:

_GUICtrlTreeView_BeginUpdate($TreeView1)

;Begin

$Option_1 = _GUICtrlTreeView_Add($TreeView1, 0, "Option 1", 0, 0)
GUICtrlSetColor(-1 , 0x0000C0)

;End

_GUICtrlTreeView_Add($TreeView1, 0, "Option 2", 1, 1)
_GUICtrlTreeView_Add($TreeView1, 0, "Option 3", 2, 2)
_GUICtrlTreeView_AddChild($TreeView1, $Option_1, "Test", 3, 3)
_GUICtrlTreeView_EndUpdate($TreeView1)

With this:

$Option_1 = GUICtrlCreateTreeViewItem("Option 1", $TreeView1)
GUICtrlSetImage($Option_1, @ScriptDir & "\Type_1.ico", 0)
GUICtrlSetColor($Option_1, 0x0000C0)
Edited by sleepydvdr

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

Change part of this code:

_GUICtrlTreeView_BeginUpdate($TreeView1)

;Begin

$Option_1 = _GUICtrlTreeView_Add($TreeView1, 0, "Option 1", 0, 0)
GUICtrlSetColor(-1 , 0x0000C0)

;End

_GUICtrlTreeView_Add($TreeView1, 0, "Option 2", 1, 1)
_GUICtrlTreeView_Add($TreeView1, 0, "Option 3", 2, 2)
_GUICtrlTreeView_AddChild($TreeView1, $Option_1, "Test", 3, 3)
_GUICtrlTreeView_EndUpdate($TreeView1)

With this:

$Option_1 = GUICtrlCreateTreeViewItem("Option 1", $TreeView1)
GUICtrlSetImage($Option_1, @ScriptDir & "\Type_1.ico", 0)
GUICtrlSetColor($Option_1, 0x0000C0)

Thank you very much :huh2:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0