Mega Code Archive

 
Categories / Delphi / VCL
 

Listbox item bitmap

//www.dronymc.cjb.net //drony@mynet.com // icq:266148308 procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var Bitmap: TBitmap; R: TRect; Mas: array[1..3] of string; i: Integer; begin Mas[1]:='Pict1.bmp'; Mas[2]:='Pict2.bmp'; Mas[3]:='Pict3.bmp'; with (Control as TListBox).Canvas do begin Bitmap:=TBitmap.Create; FillRect(Rect); Bitmap.LoadFromFile('C:\Pictures\'+Mas[Index+1]); if Bitmap<>nil then begin R:=Bounds( Rect.Left+2, Rect.Top+2, Rect.Bottom-Rect.Top-2, Rect.Bottom-Rect.top-2); StretchDraw(R,Bitmap); end; TextOut(Rect.Left+100,Rect.Top,Mas[Index+1]); Bitmap.Free; end; end;