winapilistviewcolorscustom-draw

ListView Custom Draw - Multi-colored text inside individual cell?


As far as I know you can use Custom Draw in a list-view to paint individual cells the way you want using CDDS_SUBITEM.

However, I would like to have multi-colored text within a cell. That is, I would like to, for example, set a cell's text to: "this program is called the [start red text]Red Program[end red text]" - is there a way to accomplish this?


Solution

  • Well, in your NMCUSTOMDRAW structure you get an HDC. You will need to call DrawText multiple times. You may be able to just call SetTextColor to do that, or you may have to call SelectObject and select in your own custom Pen to change the color... yay GDI.