Hi,
I have next code:
procedure TMASTERform.fotogridDrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
var
image : TImage;
foto : string;
ntop, nleft, nfirst : integer;
lfotook : boolean;
cellWidth, cellHeight: LongInt;
cvs: TCanvas;
Rect: TRect;
begin
if RASTERQuery.Active then
begin
if Sender is TDrawGrid
then cvs := TDrawGrid(Sender).Canvas
else cvs := fotogrid.Canvas;
Rect := aRect;
lfotook := true;
if (aCol = 0) and (aRow = 0)
then RASTERQuery.First
else
begin
if not RasterQuery.EOF
then RasterQuery.Next
else lfotook := false;
end;
end
else lfotook := false;
if lfotook then
begin
if RASTERQuery.FieldByName('ty').AsString = 'D'
then foto := DIR_SLIDE+RASTERQuery.FieldByName('foto_dir').AsString+'\'+RASTERQuery.FieldByName('foto').AsString
else foto := 'avi-mjpg-flv.jpg';
cellWidth := aRect.Right-aRect.Left;
cellHeight := aRect.Bottom-aRect.Top;
image := TImage.Create(Self);
try
image.Picture.LoadFromFile(foto);
image.Width := cellWidth - 10;
image.Height := cellHeight - 10;
image.AutoSize := false;
image.Proportional := true;
image.Stretch := false;
image.Cursor := crHandPoint;
ntop := Rect.Top + 5;
nleft := Rect.Left + 5;
cvs.Draw(nleft, nTop, image.Picture.Graphic);
finally
image.Free;
end;
end;
// else fotogrid.DefaultDrawCell(aCol, aRow, aRect, aState);
end;
This codes works as it should, except, the images are NOT scaled at all.
1) I want to scale all images to a defined value. Decreasing size, increasing size.
2) that image should be shown in a cell of the drawgrid.
3) Ratio between vertical and widht must be respected.
The code is functional and works except, no resizing at all !
doe somebody sees why not ?
When this is working I want to add a small panel, label beneath the image so I can put a title in ? Some body an idea for this ?
Thanks