Citation :
procedure TFormSearch.CheckListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var monimage:Tbitmap;
jpeg: TJpegImage;
R: TRect;
tabs:array [1..10] of string;
ste,ste2,cas:string;
nblignes,i,nbcaract,maxcast:integer;
begin
with (Control as TCheckListBox).Canvas do
begin
monimage:=tbitmap.Create;
jpeg := TJpegImage.Create;
if form1.mov[index].tmdb.image='Non disponible' then
begin
//form1.mov[index].image:=extractfilepath(application.exename)+'photo_non_disponible.jpg';
jpeg.LoadFromFile(extractfilepath(application.exename)+'photo_non_disponible.jpg');
end
else
if fileexists(extractfilepath(application.ExeName)+'tmpimages\'+form1.mov[index].tmdb.code_id+'.jpg') then
begin
jpeg.LoadFromFile(extractfilepath(application.ExeName)+'tmpimages\'+form1.mov[index].tmdb.code_id+'.jpg');
end;
// if form1.mov[index+1].poster=extractfilepath(application.exename)+'photo_non_disponible.jpg' then jpeg.LoadFromFile(extractfilepath(application.exename)+'photo_non_disponible.jpg');
monimage.Assign(jpeg);
FillRect(Rect);
//monimage.LoadFromFile();
if monimage<>nil then
begin
R:=Bounds(
Rect.Left+2,
Rect.Top+2,
Rect.Bottom-Rect.Top-2,
Rect.Bottom-Rect.top-2);
StretchDraw(R,monimage);
end;
Checklistbox1.canvas.Font.Size:=14;
Checklistbox1.Canvas.Font.Style := Checklistbox1.Canvas.Font.Style + [fsBold];
TextOut(Rect.left+200,Rect.Top+5,form1.mov[index].tmdb.nom);
Checklistbox1.canvas.Font.Size:=11;
Checklistbox1.Canvas.Font.Style := checklistbox1.Canvas.Font.Style - [fsBold];
Textout(Rect.left+200,Rect.TOP+5+25,'Année : '+form1.mov[index].tmdb.release_date);
Checklistbox1.canvas.Font.Size:=8;
Checklistbox1.Canvas.Font.Style := checklistbox1.Canvas.Font.Style - [fsBold];
cas:='';
maxcast:=0;
if form1.mov[index].tmdb.nbcast=0 then cas:='Pas trouvé'
else if form1.mov[index].tmdb.nbcast>4 then maxcast:=5
else maxcast:=form1.mov[index].tmdb.nbcast;
if maxcast=1 then cas:=form1.mov[index].tmdb.casts[1].nom
else
if maxcast>1 then
begin
for i:=1 to maxcast-1 do cas:=cas+form1.mov[index].tmdb.casts[i].nom+' - ';
cas:=cas+form1.mov[index].tmdb.casts[i+1].nom;
end
else cas:='';
Textout(Rect.left+200,Rect.TOP+5+45,'Avec : '+cas);
Checklistbox1.canvas.Font.Size:=8;
ste:=form1.mov[index].tmdb.resume+form1.mov[index].tmdb.code_id;
nbcaract:=100;
nblignes:=length(ste) div nbcaract;
for i:=1 to nblignes do
begin
ste2:=copy(ste,nbcaract*(i-1)+1,nbcaract);
Textout(Rect.left+200,Rect.TOP+15*i+55,ste2);
end;
if length(ste) mod nbcaract>0 then
begin
ste2:=copy(ste,nbcaract*nblignes+1,length(ste) mod nbcaract);
Textout(Rect.left+200,Rect.TOP+15*(nblignes+1)+55,ste2);
end;
//Textout(Rect.Left+140,Rect.TOP+5+50,);
//Textout(Rect.Left+140,Rect.TOP+5+50,form1.mov[index+1].liste_acteurs);
monimage.Free;
jpeg.Free;
end;// monimage.free;
end;
|