DickG Posted March 8, 2016 Share Posted March 8, 2016 (edited) I can set the color to the Parent item, but not to the Child item. So I tried using the Help file example to set the color to parent and child items. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hItem, $hImage, $iImage, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Add Child", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, "shell32.dll", 110) _GUIImageList_AddIcon($hImage, "shell32.dll", 131) _GUIImageList_AddIcon($hImage, "shell32.dll", 165) _GUIImageList_AddIcon($hImage, "shell32.dll", 168) _GUIImageList_AddIcon($hImage, "shell32.dll", 137) _GUIImageList_AddIcon($hImage, "shell32.dll", 146) _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage) _GUICtrlTreeView_BeginUpdate($idTreeView) For $x = 1 To Random(2, 10, 1) $iImage = Random(0, 5, 1) $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage) GUICtrlSetBkColor($hItem, "0xFCECB4") For $y = 1 To Random(2, 10, 1) $iImage = Random(0, 5, 1) _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage) GUICtrlSetBkColor($hItem, "0xFE304F") Next Next _GUICtrlTreeView_EndUpdate($idTreeView) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example But it doesn't change any color at all. Any idea why? Edited March 8, 2016 by DickG Link to comment Share on other sites More sharing options...
spudw2k Posted March 8, 2016 Share Posted March 8, 2016 (edited) GUICtrlSetBkColor needs a CtrlID (return from native GUICtrl functions), not a handle (return from _GUICtrl UDFs). This complicates things a little (have to apply Image List Index afterwards), but is doable. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hItem, $hImage, $iImage, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Add Child", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, "shell32.dll", 110) _GUIImageList_AddIcon($hImage, "shell32.dll", 131) _GUIImageList_AddIcon($hImage, "shell32.dll", 165) _GUIImageList_AddIcon($hImage, "shell32.dll", 168) _GUIImageList_AddIcon($hImage, "shell32.dll", 137) _GUIImageList_AddIcon($hImage, "shell32.dll", 146) _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage) _GUICtrlTreeView_BeginUpdate($idTreeView) For $x = 1 To Random(2, 10, 1) $iImage = Random(0, 5, 1) ;$hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage) $hItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView) GUICtrlSetBkColor(-1, "0xFCECB4") _GUICtrlTreeView_SetImageIndex($idTreeView, $hItem, $iImage) For $y = 1 To Random(2, 10, 1) $iImage = Random(0, 5, 1) ;_GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage) $hChild = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $hItem) GUICtrlSetBkColor(-1, "0xFE304F") _GUICtrlTreeView_SetImageIndex($idTreeView, $hChild, $iImage) Next Next _GUICtrlTreeView_EndUpdate($idTreeView) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Edited March 8, 2016 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
DickG Posted March 9, 2016 Author Share Posted March 9, 2016 Fantastic! I failed to realize the difference between using native and UDF functions! So this let me figure out how to get it to work in my own script. Thank you very much, Spudw2k! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now