ChartListbox item background color lazarus / 55-TAChart ---------------------------------------------------------------------- wp · 2011-10-24 06:59 When I change the color of a TChartListbox the background of the text items still gets painted in the clWindow color. It should be transparent instead. The legend and LegendPanel are ok. ---------------------------------------------------------------------- Ask · 2011-10-24 07:34 Fixed in r33065 ---------------------------------------------------------------------- wp · 2011-10-24 10:37 Thank you for the quick fix. Before posting I had tried to set the Brush.Style of the TCanvasDrawer to bsClear. But this did not compile. Doesn't the TCanvasDrawer have a brush? ---------------------------------------------------------------------- Ask · 2011-10-24 14:30 It has SetBrush method, but not Brush property. In this case, the fix should affect both branches of the following "if" statement, and only one of those uses drawer interface. ---------------------------------------------------------------------- wp · 2011-11-23 23:08 With the Canvas.Brush.Style set to bsClear the selected list box item is hard to read on the default clWindow-colored item background. It is better to use the Listbox color for the item background instead of painting it transparently. Also, the owner-draw state must be checked. Please the following code in TChartListbox.DrawItem Code: [Select]procedure TChartListbox.DrawItem   ....   // Unused(AState);  ---- remove, it is no longer unused.   ....   //    Canvas.Brush.Style := bsClear;   if not (odSelected in AState) then     Canvas.Brush.Color := Color;      .... ---------------------------------------------------------------------- Ask · 2011-12-07 04:48 Should be fixed in r34016. ---------------------------------------------------------------------- wp · 2011-12-07 22:13 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): Code: [Select]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; ---------------------------------------------------------------------- Ask · 2011-12-08 00:19 I see. My previous change has only fixed drawing of the selected item. Now the bug is actually in TCustomListbox code, I have submitted the patch: http://bugs.freepascal.org/view.php?id=20837 If for some reason the patch will be rejected, we can work around the problem in the way you suggested. Edit: patch applied, please test. ---------------------------------------------------------------------- wp · 2011-12-09 20:01 Thank you - it's fine now.