ShellBrowser Delphi Edition Documentation
ContentsIndexHome
PreviousUpNext
TShellBrowser.SetThumbnailProvider Method

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);

This is a global setting for each instance of a program.

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:Imagesdummy_thumnail.bmp'); end; procedure TMainForm.FormShow(Sender: TObject); begin TShellBrowser.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;
Copyright (c) 2011. All rights reserved.