10-14-2017 05:24 PM
I've seen posts but nothing directly for my issue. I have a string object on a uir panel and want to programmatically change the text color. I'm using SetCtrlAttribute with ATTR_TEXT_COLOR and giving it an RGB value (entered my own as 0x00RRGGBB, and even used MakeColor(x,y,z). No syntax or runtime errors, the text color just isn't changing. Even tried ProcessDrawEvents() after the call to SetCtrlAttribute, and even ProcessSystemEventsI() to no avail. Help for the ATTR_TEXT_COLOR lists string objects as ones it works for. What gives?
Solved! Go to Solution.
10-15-2017 05:18 PM
Could it be that the panel that hosts the string control has the "conform to system colors" attribute set?
10-16-2017 12:13 AM
If Roberto's guess is not the issue, is your text control on a tab panel?
You can also check the return value of the SetCtrlAttribute function. If it is returning negative it is telling you why it is failing.
10-16-2017 10:55 AM
Thanks, Roberto. Good point, but no, it isn't checked
10-16-2017 11:25 AM
If neither my guess nor ebalci's theory is true, can you create a small example that exhibits this behaviour? This will make easier for us to discriminate the possible problems and suggest the best solution.
10-16-2017 11:28 AM
This is a good point as well. Embarrassed to admit it didn't come to mind. I tend to work with minimal code to begin with and return to add exception handling later, which I don't particularly like about my development.
Anyway, problem found: code in another area was stepping on the color change command, and resetting it.
Sorry guys, and I do appreciate your patience and understanding.
10-16-2017 05:09 PM
It happens to me all the time! As far as projects grow up in complexity it always happens some weird code tangle that messes things up!
Anyway I'm happy you did find the problem.
09-10-2020 01:16 PM
Another possible oops: make sure the first parameter in the set control attribute is the panel handle, not the panel ID.