dts256 Posted June 9, 2017 Share Posted June 9, 2017 Hi all. I'm having a problem getting the text colour of a treeview item. I can "set" it ok but I can't seem to "get" the text colour. I'm creating the treeview item using a native Autoit function so I can get a control id (rather than a handle). This works to set the text colour, but I can't get the text colour using the UDF function _GUICtrlTreeView_GetTextColor whether I use a handle or a control ID. $TreeView = GUICtrlCreateTreeView(10, 150, 150, 300, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $CidTestItem = GUICtrlCreateTreeViewItem("Test Item", $TreeView) GUICtrlSetColor($CidTestItem, 0x0000C0) ;Blue $hTestItem = _GUICtrlTreeView_GetItemHandle($TreeView, $CidTestItem) $TextColourUsingHandle = _GUICtrlTreeView_GetTextColor($hTestItem) $TextColour1UsingCid = _GUICtrlTreeView_GetTextColor($CidTestItem) I've attached a complete runnable script. Am I missing something ? Test Get Text Colour.au3 Link to comment Share on other sites More sharing options...
corgano Posted June 10, 2017 Share Posted June 10, 2017 Maybe try using the UDF function to create the treeview item instead of the standard function, they may work differently behind the scenes in a completely non-obvious way. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
dts256 Posted June 10, 2017 Author Share Posted June 10, 2017 Hi corgano, Thank you for your reply, a control id is needed for GUICtrlSetColor though, and the UDF functions that create a treeview item return a handle. Link to comment Share on other sites More sharing options...
dts256 Posted June 10, 2017 Author Share Posted June 10, 2017 Ok, it appears that _GUICtrlTreeView_SetTextColor and _GUICtrlTreeView_GetTextColor (UDF Functions) set (and get) the text colour for the treeview itself, which explains why they don't work for a treeview item, and why I need to use GUICtrlSetColor. There seems to be no corresponding GUICtrlGetColor (or equivalent, that i can find) though. Link to comment Share on other sites More sharing options...
corgano Posted June 10, 2017 Share Posted June 10, 2017 (edited) There is a UDF function for setcolor and setbkcolor as well Take a look through the help file to see what functions are available. Switching to udf-based functions only might make it work Edited June 10, 2017 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
dts256 Posted June 11, 2017 Author Share Posted June 11, 2017 Hi Corgano, That's the problem. There doesn't seem to be a UDF to set/get the text colour of a treeview item. There is _GUICtrlTreeView_SetTextColor and _GUICtrlTreeView_GetTextColor These only work for an entire treeview, but not for a treeview item. I have to use the native function GUICtrlSetColor (which needs a control id) as it appears to be be the only way to set the text colour of a treeview item. The only problem is that I can't "get" the text colour after I've used it. I've managed to code round this problem, but it sure would have been a lot easier if there was a way to get the text colour. Anyway, thank you for trying to help me out. 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