Sorry, it's not working. Just set the color of the Listbox to something that is not white -- the items will have a white background, but the rest of the listbox has the new background color. See the attached screen shots.
This code works fine for me (although the selection highlights only the text):
procedure TChartListbox.DrawItem(
AIndex: Integer; ARect: TRect; AState: TOwnerDrawState);
{ draws the listbox item }
const
UNTHEMED_FLAGS: array [TCheckboxesStyle, Boolean] of Integer = (
(DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED),
(DFCS_BUTTONRADIO, DFCS_BUTTONRADIO or DFCS_CHECKED)
);
THEMED_FLAGS: array [TCheckboxesStyle, Boolean] of TThemedButton = (
(tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal),
(tbRadioButtonUnCheckedNormal, tbRadioButtonCheckedNormal)
);
var
id: IChartDrawer;
rcb, ricon: TRect;
te: TThemedElementDetails;
x: Integer;
ch: Boolean;
begin
Unused(AState);
if FChart = nil then exit;
CalcRects(ARect, rcb, ricon);
if cloShowCheckboxes in Options then begin
ch := Checked[AIndex];
if ThemeServices.ThemesEnabled then begin
te := ThemeServices.GetElementDetails(THEMED_FLAGS[FCheckStyle, ch]);
ThemeServices.DrawElement(Canvas.Handle, te, rcb);
end
else
DrawFrameControl(
Canvas.Handle, rcb, DFC_BUTTON, UNTHEMED_FLAGS[FCheckStyle, ch]);
x := rcb.Right;
end
else
x := ARect.Left;
if not (odSelected in AState) then
Canvas.Brush.Color := Color;
if cloShowIcons in Options then begin
id := TCanvasDrawer.Create(Canvas);
id.Pen := Chart.Legend.SymbolFrame;
FLegendItems[AIndex].Draw(id, ricon);
end
else
Canvas.TextOut(x + 2, ARect.Top, FLegendItems.Items[AIndex].Text);
end;