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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
procedure TChild.vtGetHintSize(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var R: TRect);
var
PR: TPatClass;
aBMP: TBitmap;
aPNG: TPNGImage;
begin
PR:=GetPointerFromTree(Sender, Node);
if Assigned(PR) then
begin
case Column of
0: if FileExists(Path+'\'+cPathPicture+'\'+PR.Number+'.png') then
begin
aBMP := TBitmap.Create;
aPNG := TPNGImage.Create;
try
aPNG.LoadFromFile(Path+'\'+cPathPicture+'\'+PR.Number+'.png');
aBMP.Width:=aPNG.Width div 10;
aBMP.Height:=aPNG.Height div 10;
R:=Rect(0,0,aBMP.Width,aBMP.Height);
//Copie de l'image avec redimensionnement sur le canvas du TBitmap
aBMP.Canvas.StretchDraw(R, aPNG);
Canvas.Handle := THintWindow.Create(TVirtualDrawTree(Sender)).Canvas.Handle;
Canvas.Assign(aBMP);
finally
aPNG.Free;
aBMP.Free;
end;
InflateRect(R, +5, +5);
end;
end;
end; {* proc .vtGetHintSize *}
procedure TChild.vtDrawHint(Sender: TBaseVirtualTree;
HintCanvas: TCanvas; Node: PVirtualNode; R: TRect; Column: TColumnIndex);
var
PR: TPatClass;
aBMP: TBitMap;
aPNG: TPNGImage;
begin
PR:=GetPointerFromTree(Sender, Node);
if Assigned(PR) then
begin
case Column of
0: if FileExists(Path+'\'+cPathPicture+'\'+PR.Number+'.png') then
begin
aBMP := TBitmap.Create;
aPNG := TPNGImage.Create;
try
aPNG.LoadFromFile(Path+'\'+cPathPicture+'\'+PR.Number+'.png');
aBMP.Width:=aPNG.Width div 10;
aBMP.Height:=aPNG.Height div 10;
R:=Rect(0,0,aBMP.Width,aBMP.Height);
//Copie de l'image avec redimensionnement sur le canvas du TBitmap
aBMP.Canvas.StretchDraw(R, aPNG);
HintCanvas.Assign(aBMP);
finally
aPNG.Free;
aBMP.Free;
end;
InflateRect(R, +5, +5);
end;
end;
end; {* proc .vtDrawHint *} |
Partager