I have create list a listview
list[0]=CreateWindow(WC_LISTVIEW,L"",WS_DLGFRAME|WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_SINGLESEL,-,-,-,-,hwnd,NULL,hInstance,NULL);
LVCOLUMN lvcolumn;
lvcolumn.mask = LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;
lvcolumn.fmt = LVCFMT_CENTER;
lvcolumn.pszText = L"a";
lvcolumn.cx = 100;
ListView_InsertColumn(list[0],0,&lvcolumn);
lvcolumn.pszText = L"b";
ListView_InsertColumn(list[0],1,&lvcolumn);
lvcolumn.pszText = L"c";
ListView_InsertColumn(list[0],2,&lvcolumn);
lvcolumn.pszText = L"d";
ListView_InsertColumn(list[0],3,&lvcolumn);
And I use LPNMLVCUSTOMDRAW to insert color item
case WM_NOTIFY:
if( ((LPNMHDR)lParam)->code == NM_CUSTOMDRAW){
switch( ((LPNMLVCUSTOMDRAW)lParam)->nmcd.dwDrawStage){
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
{
LPNMLVCUSTOMDRAW customDraw = (LPNMLVCUSTOMDRAW)lParam;
customDraw->clrText = getcolor();
return CDRF_NEWFONT;
break;
}
default: return CDRF_DODEFAULT;
}
}
break;
getcolor is function response colorref. Each item have it own text color. But when the parent window is hide and show again the item color is change. So how to keep it not change or we have another way to set text color
One more I create an new listview item by this way (in case someone need it)
ListView_InsertItem(hwndlist,&lvitem);
ListView_SetItemText(hwndlist,i,k,(LPWSTR)strarr[k].c_str());