3
votes

I have a Delphi 6 application that owner-draws icons in a TListBox row along with some text. The TListBox's Style is set to lbOwnerDrawVariable. The problem I'm having is when an item is selected. The highlight color used by the list box to change the background color of the selected row is making the icon look terrible because the icon has transparent pixels (my assumption based on the visible evidence), and those pixels are changed to the background color thereby ruining the image. Is there an easy way to force the transparent pixels to be drawn a certain color so I can eliminate this problem? I am using the TImageList.Draw() method to draw the icon on the TListBox canvas.

1
on your owner draw item method, you may draw a small rectangle with the brush color you want on the area to be covered by the icon just before you draw the icon.PA.
@PA - I'd vote if the comment was an answer.Sertac Akyuz
thanks, but in my opinion, this is not an answer to the OP question. It's a workaround.PA.

1 Answers

4
votes

You can use the Draw method with DrawingStyle set to 'dsNormal' and setting whatever color you wish to use as the background to BkColor:

ImageList1.BkColor := clHighlight;
ImageList1.Draw(Canvas, 0, 0, 0, dsNormal, itImage);

If Delphi 6 does not have the Draw overload with 'DrawingStyle', then:

ImageList1.BkColor := clHighlight;
ImageList1.DrawingStyle := dsNormal;
ImageList1.Draw(Canvas, 0, 0, 0);