Thanks Alain, this works (almost)! I am using your WTL::CControlDialogImpl to show the listbox in a modal dialog. The drawing is a little off now.
void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT item)
if (item->itemID == -1) return;
WTL::CDCHandle dc(item->hDC);
dc.GradientFillRect(item->rcItem, RGB(200,200,200), RGB(10,10,10), false);
if (item->itemState == ODS\_FOCUS) {
dc.SetTextColor(RGB(255,255,255));
} else {
dc.SetTextColor(RGB(255,255,255));
}
WCHAR text\[1024\];
int chars = m\_Ctrl.GetText(item->itemID, text);
dc.SetBkMode(TRANSPARENT);
dc.SelectFont(font);
dc.DrawText(text, chars, &item->rcItem, DT\_NOPREFIX | DT\_SINGLELINE | DT\_CENTER | DT\_VCENTER | DT\_END\_ELLIPSIS);
}
After some rows the gradients stop to show up and the background is just the standard window color.
Happy coding, Philipp Kursawe