Using multiple foreground colors for text in a listbox cell

Before I start reinventing the wheel, is it possible and has anyone worked out a mechanism for providing multiple foreground text colors in a Listbox cell? Nothing in the Language Reference seems to indicate yes or no.

For instance, given a string such as:

[L165] FINISH - 0 warnings, 0 errors, exit code = 0

I’d like to color code the brackets section, the word FINISH, and the exit code value.

I’ve tried a basic subdivision of the string and processing it in the CellTextPaint event, but I either get one color or a UnsupportedFunction exception.

s="[L165] FINISH - 0 warnings, 0 errors, exit code = 0"
z=instr(s,"]")
y=g.textascent+(g.height-g.textheight)/2
x=0
g.forecolor=&cff0000
g.drawstring left(s,z),x,y
x=x+g.stringwidth(left(s,z))
s=mid(s,z+1)
g.forecolor=&c00ff00
z=instr(s,"-")
g.drawstring left(s,z),x,y
x=x+g.stringwidth(left(s,z))
s=mid(s,z+1)
g.forecolor=&c0000ff
g.drawstring s,x,y

rough and brute force, not to mention off the top of my head…

[quote]
code is for illustration purposes only, and it is up to the developer to decide if it meets their needs and to modify it to fit their situation[/quote]

Examples exists in the LR. Read it carefully.

Also: this question arise here from time to time too.

DrawString - Duh! Thanks, Dave!