here is the question I did ask before: I have a listview REPORT with fullrowselect style everything works fine, but after i used customdraw I faced a problem such pic included, it seems I click on the item col 3 it becomes bold and more bold.. Picture[^] if i use listview_update the bold text from the col 3 will be gone so why happens? and i just want to click on the raw without having that bold problem? any ideas? The Code
if (lpNMHdr->code == NM_CUSTOMDRAW)
{
LPNMLVCUSTOMDRAW lpCD = (LPNMLVCUSTOMDRAW)lpNMHdr;
if (lpCD->nmcd.dwDrawStage == CDDS_PREPAINT)
{
return CDRF_NOTIFYITEMDRAW;
}
if (lpCD->nmcd.dwDrawStage == CDDS\_ITEMPREPAINT)
{
return CDRF\_NOTIFYSUBITEMDRAW;
}
if (lpCD->nmcd.dwDrawStage == (CDDS\_ITEMPREPAINT|CDDS\_SUBITEM))
{
if (lpCD->iSubItem == 0) //detect which subitem is being drawn
{
LPCTSTR lpcszBuf1 = \_T("example");
LPCTSTR lpcszBuf2 = \_T("text");
RECT iR = { 0 };
ListView\_GetSubItemRect(lpCD->nmcd.hdr.hwndFrom, lpCD->nmcd.dwItemSpec, lpCD->iSubItem, LVIR\_BOUNDS, &iR);
SetBkMode(lpCD->nmcd.hdc, TRANSPARENT);
SIZE sz = { 0 };
GetTextExtentPoint32(lpCD->nmcd.hdc, lpcszBuf1, 7, &sz);
SetTextColor(lpCD->nmcd.hdc, RGB(255, 0, 0));
DrawText(lpCD->nmcd.hdc, lpcszBuf1, -1, &iR, DT\_LEFT);
iR.left += sz.cx;
SetTextColor(lpCD->nmcd.hdc, RGB(0, 255, 0));
DrawText(lpCD->nmcd.hdc, lpcszBuf2, -1, &iR, DT\_LEFT);
return CDRF\_SKIPDEFAULT;
}
}
So someone answered me: If you draw it yourself you need to clear the background as well, which you are not doing. Try using OPAQUE instead of TRANSPARENT. However, I used OPAQUE but it does not help a lot so, I am trying now with clear the background: the message is wm_ERASEBACKGROUND but what I suppose to do? should I add the code there or what?