title: How can I modify the font colors of individual characters in a ListView subitem?
body: <p>I was writing an app using the Windows API, and I wanted to know how to make a listview with subitems that contain multi-colored text.</p>
  
  <p>To clarify, here is a picture of how it is implemented in API Monitor:
  <img src="https://i.stack.imgur.com/Muus4.png" alt=""></p>
  
  <p>Notice that in the "API" column, the text has multiple colors, like it is rich text or something. I was wondering how I would do this.</p>
  
  <p>Someone told me to do something with custom-drawing, but he wasn't sure. I looked into it, and I handled <code>NM_CUSTOMDRAW</code>. Here is the result of my test: <br>
  <img src="https://i.stack.imgur.com/Ylg7n.png" alt=""></p>
  
  <p>And here is the code:</p>
  
  <pre><code>inline LRESULT HandleWM_NOTIFY(LPARAM lParam)
  {
     switch (((LPNMHDR)lParam)-&gt;code)
     {
        case NM_CUSTOMDRAW:
        {
           switch (((LPNMHDR)lParam)-&gt;idFrom)
           {
              case ID_LISTVIEW1:
              {
                 LPNMLVCUSTOMDRAW lpNMLVCD = (LPNMLVCUSTOMDRAW)lParam;
                 if (lpNMLVCD-&gt;nmcd.dwDrawStage == CDDS_PREPAINT)
                 {
                    return CDRF_NOTIFYITEMDRAW;
                 }
                 else if (lpNMLVCD-&gt;nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
                 {
                    COLORREF crText;
                    switch (lpNMLVCD-&gt;nmcd.dwItemSpec % 3)
                    {
                       case 0:
                          crText = RGB(255, 0, 0);
                          break;
                       case 1:
                          crText = RGB(0, 255, 0);
                          break;
                       case 2:
                          crText = RGB(0, 0, 255);
                          break;
                    }
  
                    lpNMLVCD-&gt;clrText = crText;
                    lpNMLVCD-&gt;
                 }
  
                 return CDRF_DODEFAULT;
              }
              default: break;
           }
  
           break;
        }
  
        default: break;
     }
  
     return 0;
  }
  </code></pre>
  
  <p>Using the <code>NM_CUSTOMDRAW</code> method, I can't modify the font colors of individual characters; I can only modify the font color of everything in the subitem, which is not what I want.</p>
  
  <p>How can I achieve what API monitor does? I have a feeling this is going to be very difficult, but any suggestions are welcome.</p>