ComboBox with bitmaps
Put
a T../ImageList (../ImageList1) and a TComboBox (ComboBox1) in your form change the
Style property of ComboBox1 to csOwnerDrawVariable and put the next code in
their OnDrawItem event:
Procedure
TForm1.ComboBox1DrawItem ( Control : TWinControl ; Index : Integer ;
Rect : TRect ; State :
TOwnerDrawState ) ;
Var
bTemp : TBitmap ;
bTemp := TBitmap.Create ;
If Index < ../ImageList1.Count
Then
Begin
../ImageList1.GetBitmap ( Index , bTemp ) ;
End ;
With ( Control As TComboBox ) 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 ;