diff --git a/windows/table.cpp b/windows/table.cpp index 12deab16..66de886e 100644 --- a/windows/table.cpp +++ b/windows/table.cpp @@ -174,20 +174,6 @@ static LRESULT onNM_CUSTOMDRAW(uiTable *t, NMLVCUSTOMDRAW *nm) nm->clrText = blend(nm->clrTextBk, r, g, b, a); } } -if (nm->iSubItem != 0) { -HWND header; -LRESULT margin; -header = (HWND) SendMessageW(t->hwnd, LVM_GETHEADER, NULL, NULL); -margin = SendMessageW(header, HDM_GETBITMAPMARGIN, 0, 0); -//nm->rcText.left -= margin; -printf("%d %d %d %d\n", -(int)(nm->nmcd.rc.left), -(int)(nm->nmcd.rc.top), -(int)(nm->nmcd.rc.right), -(int)(nm->nmcd.rc.bottom)); -FillRect(nm->nmcd.hdc, &(nm->nmcd.rc), GetSysColorBrush(COLOR_ACTIVECAPTION)); -return CDRF_SKIPDEFAULT; -} // TODO draw background on image columns if needed ret = CDRF_NEWFONT; break; diff --git a/windows/tableimages.cpp b/windows/tableimages.cpp index b8db37af..0923f409 100644 --- a/windows/tableimages.cpp +++ b/windows/tableimages.cpp @@ -144,6 +144,8 @@ HRESULT uiprivNM_CUSTOMDRAWImagesCheckboxes(uiTable *t, NMLVCUSTOMDRAW *nm, LRES uiprivTableColumnParams *p; int index; RECT r; + RECT cellRect; + LONG yoff; if (nm->nmcd.dwDrawStage == (CDDS_SUBITEM | CDDS_ITEMPREPAINT)) { *lResult |= CDRF_NOTIFYPOSTPAINT; @@ -166,14 +168,23 @@ HRESULT uiprivNM_CUSTOMDRAWImagesCheckboxes(uiTable *t, NMLVCUSTOMDRAW *nm, LRES logLastError(L"LVM_GETSUBITEMRECT"); return E_FAIL; } -#if 0 - // TODO this is offset by one pixel on my system and everything I've found indicates this should not be happening??? + // the real listview also does this :| + ZeroMemory(&cellRect, sizeof (RECT)); + r.left = LVIR_BOUNDS; + r.top = nm->iSubItem; + if (SendMessageW(t->hwnd, LVM_GETSUBITEMRECT, nm->nmcd.dwItemSpec, (LPARAM) (&cellRect)) == 0) { + logLastError(L"LVM_GETSUBITEMRECT cell"); + return E_FAIL; + } + yoff = ((cellRect.bottom - cellRect.top) - (r.bottom - r.top)) / 2; + r.top += yoff; + r.bottom += yoff; +if ((nm->nmcd.dwItemSpec%2)==0) if (ImageList_Draw(t->smallImages, index, nm->nmcd.hdc, r.left, r.top, ILD_NORMAL) == 0) { logLastError(L"ImageList_Draw()"); return E_FAIL; } -#endif return S_OK; }