argh, what is wrong?!
what the heck is wrong with it??!!??! it drives me crazy!
case WM_NOTIFY:
{
switch(LOWORD(wParam))
{
case IDC_LIST:
{
if(((LPNMHDR)lParam)->code == NM_CUSTOMDRAW)
{
NMLVCUSTOMDRAW *cdraw = (NMLVCUSTOMDRAW*)lParam;
if (cdraw->nmcd.dwDrawStage == CDDS_PREPAINT)
return CDRF_NOTIFYITEMDRAW;
if (cdraw->nmcd.dwDrawStage == CDDS_ITEMPREPAINT || cdraw->nmcd.dwDrawStage == CDDS_SUBITEM)
{
COLORREF crText;
if ( cdraw->iSubItem==2 )
crText = RGB(255,0,0);
else if ( cdraw->iSubItem==1 )
crText = RGB(0,255,0);
else
crText = RGB(128,128,255);
cdraw->clrText = crText;
return CDRF_DODEFAULT;
}
}
}
}
}
the message never arrives if (cdraw->nmcd.dwDrawStage == CDDS_ITEMPREPAINT || cdraw->nmcd.dwDrawStage == CDDS_SUBITEM)
i have seen other src codes and it all works well there (MFC apps !@!@#!@)
do i need to set my listView to have some style or something?
[1566 byte] By [
Bengi] at [2007-11-18 3:48:01]

# 1 Re: argh, what is wrong?!
yesssssssssssss i got it to work!!
finally a good Pure API code that actually works,
i found it deep inside msdn!
this is what we need to do in the WM_NOTIFY:
if(((LPNMHDR)lParam)->code == NM_CUSTOMDRAW)
{
SetWindowLong(hWnd, DWL_MSGRESULT, (LONG)ProcessCustomDraw(lParam));
return TRUE;
}
and let the result function to be:
LRESULT ProcessCustomDraw (LPARAM lParam)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT : //Before the paint cycle begins
//request notifications for individual listview items
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT: //Before an item is drawn
if (iSelect == (int)lplvcd->nmcd.dwItemSpec)
{
//customize item appearance
lplvcd->clrText = RGB(255,255,255);
lplvcd->clrTextBk = RGB(0,0,255);
//To set a custom font:
//SelectObject(lplvcd->nmcd.hdc, <your custom HFONT>);
return CDRF_NEWFONT;
}
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT: //Before a subitem is drawn
if (iSelect == (int)lplvcd->nmcd.dwItemSpec)
{
if (0 == lplvcd->iSubItem)
{
//customize subitem appearance for column 0
lplvcd->clrText = RGB(255,255,255);
lplvcd->clrTextBk = RGB(255,0,0);
//To set a custom font:
//SelectObject(lplvcd->nmcd.hdc, <your custom HFONT>);
return CDRF_NEWFONT;
}
else if (1 == lplvcd->iSubItem)
{
//customize subitem appearance for columns 1..n
//Note: setting for column i carries over to columnn i+1 unless
// it is explicitly reset
lplvcd->clrTextBk = RGB(0,255,0);
return CDRF_NEWFONT;
}
}
}
return CDRF_DODEFAULT;
}
now we can play with Colors!!! finally gotcha !@#@!#!@#!@
:D :D :D
Bengi at 2007-11-9 13:03:28 >
