Bonjour à toutes et à tous,

J'ai besoin d'afficher dans un DBGrid des images selon des conditions, vous allez me dire VA VOIR LA FAQ abruti de Buzz..., vous pourriez rester poli éH OH

... humm déjà fais + d'autre lien évidement.

Base ACCESS / ADODB / D2009

Voilà comment je souhaite procéder :
1) Dans mon unité commune
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
type
  TFileExtension = Record
    eExtension  : String;
    eImage      : TImage;
  end;
 
  FileExtension     : Array of TFileExtension;
 
procedure LectureExtension;
var
  n : Integer;
begin
 
  SetLength(FileExtension,0);
  Finalize(FileExtension);
 
  With FData.QryCommun do
  begin
    Sql.Clear;
    Sql.Add('Select * From FileExtensions');
    try
      Active := True;
      SetLength(FileExtension,Recordset.RecordCount);
      for n := 0 to High(FileExtension) do
      begin
        FileExtension[n].eExtension  := FieldByName('Extension').AsString;
        FileExtension[n].eImage      := TImage(FieldByName('Image'));
        next;
      end;
    finally
      Close;
    end;
  end;
 
end;
2) Au Create de la form principal, je charge les images (pas plus de 30)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
procedure TFPrincipal.FormCreate(Sender: TObject);
begin
// ...
 LectureExtension;
// ...
end;
3) Dans le DrawCell de mon DBGrid je tente de d'afficher l'image sauf que je ne sais pas comment traduire le eImage

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
procedure TFPrincipal.SMDBGridGEDDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
Var
  i: Byte;
  xRect: TRect;
  xColSort: String;
begin
  With Sender as TSMDBGrid Do With Canvas Do
  Begin
    if DataSource.DataSet.RecordCount > 0 then
    begin

      xRect := Rect;
      FillRect(xRect);

// ...

      if (Column.FieldName = 'FExtension' ) then
      begin
        for I := Low(FileExtension) to High(FileExtension) do
        begin
           if FileExtension[i].eExtension = DataSource.DataSet.FieldByName('FExenstion').AsString then

           ???????? FileExtension[I].eImage   ?????????

        end;

        xRect := Rect;
        xRect.Left := Rect.Left + <eImage>.Width + 2;
      end;

      DefaultDrawColumnCell(xRect, DataCol, Column, State);
    end;
  end;

end;
Comment puis'je faire pour l'afficher ? (en considèrent que mes images sont toutes des PNG ou toute des BMP peu importent mais qu'un seul format.)