ListBox with bitmaps
Put
a T../ImageList (../ImageList1) and a TListBox (ListBox1) in your form change the
Style property of ListBox1 to lbOwnerDrawFixed and put the next code in their
OnDrawItem event:
Procedure
TForm1.ListBox1DrawItem ( Control : TWinControl ; Index : Integer ;
Rect : TRect ; State :
TOwnerDrawState ) ;
Var
bTemp : TBitmap ;
Begin
bTemp := TBitmap.Create ;
If Index < ../ImageList1.Count
Then
Begin
../ImageList1.GetBitmap ( Index , bTemp ) ;
End ;
With ( Control As TListBox ) Do
Begin
Canvas.FillRect ( Rect ) ;
Canvas.TextOut
( Rect.Left + ../ImageList1.Height + 2 , Rect.Top , Items[ Index ] ) ;
Canvas.Draw (
Rect.Left , Rect.Top , bTemp ) ;
End ;
bTemp.Free ;
End ;