Newsgroup: it.comp.lang.c++
Titolo: borland c++ builder listview - colore del testo

Qualcuno sa dirmi come cambiare il colore del testo di un solo subitems?

Qualcuno sa dirmi come cambiare il colore del testo di un solo subitems?
Spedita fattura per questo codice a 
arc...@microsigma.it
///////////////////////////////////////////////////////////////////////////
static LRESULT ProcessCustomDraw (LPARAM lParam)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW) lParam;
switch (lplvcd->nmcd.dwDrawStage)
   {
   case CDDS_PREPAINT:
      return CDRF_NOTIFYITEMDRAW;
   case CDDS_ITEMPREPAINT:
      return CDRF_NOTIFYSUBITEMDRAW;
   case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
      if (lplvcd->iSubItem == 1)
         {
         lplvcd->clrText   = RGB (255,0,0);
         lplvcd->clrTextBk = RGB (255,255,0);
         return CDRF_NEWFONT;
         }
      else
         {
         lplvcd->clrText   = RGB (0,0,0);
         lplvcd->clrTextBk = RGB (255,255,255);
         return CDRF_NEWFONT;
         }
/*      if (lplvcd->nmcd.dwItemSpec == 5)   // Riga
         {
         lplvcd->clrText   = RGB (0,0,0);
         lplvcd->clrTextBk = RGB (255,0,0);
         return CDRF_NEWFONT;
         }*/
      break;
   }
return CDRF_DODEFAULT;
}
///////////////////////////////////////////////////////////////////////////
static void InitListView (HWND hDlg)
{
LVCOLUMN lvc;
LVITEM lvI;
HWND hList;
DWORD dwStyle;
int f,g;
char Str [50];
hList = GetDlgItem (hDlg,IDC_LISTVIEW);
SendMessage (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,
                                   LVS_EX_FULLROWSELECT |
LVS_EX_GRIDLINES);
dwStyle = GetWindowLong (hList,GWL_STYLE);
SetWindowLong (hList,GWL_STYLE,dwStyle | LVS_SHOWSELALWAYS);
// Header
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
lvc.cx
 = 78;
lvc.pszText = "Uno";
lvc.cchTextMax = strlen (lvc.pszText);
lvc.iSubItem = 0;
ListView_InsertColumn (hList,0,&lvc);
lvc.cx
 = 67;
lvc.pszText = "Due";
lvc.cchTextMax = strlen (lvc.pszText);
lvc.iSubItem = 1;
ListView_InsertColumn (hList,1,&lvc);
lvc.cx
 = 90;
lvc.pszText = "Tre";
lvc.cchTextMax = strlen (lvc.pszText);
lvc.iSubItem = 2;
ListView_InsertColumn (hList,2,&lvc);
for (f=0;f<10;f++)      // Item
   for (g=0;g<3;g++)      // Subutem
      {
      lvI.mask = LVIF_TEXT;
      lvI.cchTextMax = 20;
      lvI.iItem = f;
      lvI.iSubItem = g;
      sprintf (Str,"%d",(int) (((double) rand () /
                          (double) RAND_MAX) * 1000000));
      lvI.pszText = Str;
      if (!g)
         SendMessage (hList,LVM_INSERTITEM,0,(LPARAM) &lvI);
      else
         SendMessage (hList,LVM_SETITEM,0,(LPARAM) &lvI);
      }
}
///////////////////////////////////////////////////////////////////////////
static INT_PTR CALLBACK DlgProc (HWND hDlg,UINT uMsg,WPARAM
wParam,LPARAM lParam)
{
switch (uMsg)
   {
   case WM_INITDIALOG:
      InitListView (hDlg);
      return TRUE;
   case WM_NOTIFY:
      if (LOWORD (wParam) != IDC_LISTVIEW)
         break;
      switch (((LPNMHDR)lParam)->code)
         {
         case NM_CUSTOMDRAW:
            SetWindowLong (hDlg,DWL_MSGRESULT,
                        (LONG) ProcessCustomDraw (lParam));
            return TRUE;
         }
      break;
   case WM_COMMAND:
      switch (LOWORD (wParam))
         {
         case IDOK:
         case IDCANCEL:
            EndDialog (hDlg,wParam);
            return TRUE;
         }
   }
return FALSE;
}
///////////////////////////////////////////////////////////////////////////
int APIENTRY WinMain (HINSTANCE hInstance,HINSTANCE
hPrevInst,LPSTR lpCmdLine,int nCmdShow)
{
INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
icc.dwICC = ICC_WIN95_CLASSES;
if (InitCommonControlsEx (&icc) == FALSE)
   return FALSE;
srand ((unsigned) time (NULL));
DialogBox (hInstance,MAKEINTRESOURCE
(IDD_DLG_VIEW),NULL,DlgProc);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////