Pergunta

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.

Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top