ShellBrowser Delphi Components Documentation
ContentsIndexHome
Example 2

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;