ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
Jam.Shell.Thumbnail.TJamThumbnailExtractor.SetThumbnailProvider

Allows to set a callback function that can supply a thumbnail image in case the system cannot provide one.

Syntax
Pascal
class procedure SetThumbnailProvider(pProvider: TOnThumbnailUnavailable);
Parameters 
Description 
pProvider: TOnThumbnailUnavailable 
The callback function that can supply a thumbnail image.  

This is a global setting for each instance of a program. The image supplied the handler will be used in both the TJamThumbnailImage, as well as the TJamShellList when thumbnails are displayed. The given bitmap will be freed automatically when no longer needed.

This sample code loads a default image for each thumbnail which cannot be provided.

procedure TMainForm.MyThumbnailProvider(const Path: Unicodestring; Width, Height: Integer; out Bitmap: TBitmap);
begin
 Bitmap := TBitmap.Create;
 Bitmap.LoadFromFile('X:\Images\dummy_thumnail.bmp');
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
  TJamThumbnailExtractor.SetThumbnailProvider(Self.MyThumbnailProvider);
  ...
end;

This sample code provides a thumbnail for WMF-files, for which Windows 7 is missing a thumbnail provider.

procedure TMainForm.MyThumbnailProvider(const Path: Unicodestring; Width, Height: Integer; out Bitmap: TBitmap);
var APicture: TPicture;
begin
  if LowerCase(ExtractFileExt(Path)) = '.wmf' then begin
    APicture := TPicture.Create;
    try
      APicture.LoadFromFile(Path);
      Bitmap := TBitmap.Create;
      Bitmap.PixelFormat := pf24bit;
      Bitmap.Width := Width;
      Bitmap.Height := Height;
      Bitmap.Canvas.Lock;///Important in multithreaded applications, see http://qc.embarcadero.com/wc/qcmain.aspx?d=55871
      Bitmap.Canvas.StretchDraw(Rect(0,0,Width,Height), APicture.Graphic);
      Bitmap.Canvas.Unlock;
    finally
      APicture.Free;
    end;///try..finally
  end;///if
end;