dabei wird der style von listbox1 auf lbownerdrawvariable gestellt:
könnt ihr mal das testen, ich finde den fehler nicht, denn bei mir zeigt er nix an.
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
| procedure TForm1.Button1Click(Sender: TObject); begin ListBox1.Items.AddObject( Edit1.Text,Image1.Picture.Bitmap); end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var Bitmap:TBitmap; Offset:Integer; r1,r2:TRect; begin Offset:=0; with (Control as TListBox).Canvas do begin FillRect( Rect); Bitmap:=TBitmap( TListBox( Control).Items.Objects[Index]); if Bitmap<>nil then begin r1:=Bounds( Rect.Left+2,Rect.Top+2,Bitmap.Width,Bitmap.Height); r2:=Bounds( 0,0,Bitmap.Width,Bitmap.Height); CopyRect( r1,Bitmap.Canvas,r2); Offset:=Bitmap.width+8; end; // Text anzeigen TextOut( Rect.Left+Offset,Rect.Top,TListBox( Control).Items[Index]) end; end; |