ShellBrowser Delphi Components Documentation
|
Interface that can be used to provide own custom preview handler implementations. A custom PreviewHandler can be passed in TJamFilePreview.OnLoadPreview.
ICustomPreviewHandler = interface;
type TAnimatedImagePreviewHandler = class(TInterfacedObject, ICustomPreviewHandler) private fImage: TSkAnimatedImage; strict protected procedure Resize; procedure Unload; function Load(sender: TJamFilePreview; const pPath: string): Boolean; end; { TAnimatedImagePreviewHandler } function TAnimatedImagePreviewHandler.Load(sender: TJamFilePreview; const pPath: string): Boolean; begin fImage := TSkAnimatedImage.Create(sender); fImage.Parent := sender; fImage.Align := alClient; fImage.LoadFromFile(pPath); exit(true); end; procedure TAnimatedImagePreviewHandler.Resize; begin //alClient end; procedure TAnimatedImagePreviewHandler.Unload; begin fImage.Visible := false; fImage.Parent := nil; FreeAndNil(fImage); end; procedure TMainForm.JamFilePreview1LoadPreview(Sender: TObject; eventArgs: TJamFilePreviewLoadPreviewEventArgs); begin // This example shows how to use the HTML preview handler for files with the extensions CSM: if LowerCase(ExtractFileExt(eventArgs.Path)) = '.csm' then eventArgs.PreviewHandlerGuid := StringToGUID('{F8B8412B-DEA3-4130-B36C-5E8BE73106AC}'); // The following example checks the PreviewHandler that will be used, and forces the loading and unloading of such previews // to the GUI thread. Doing so can be a workaround for rare cases where an external previewhandler has problems when // being executed to a non-gui thread. if (eventArgs.PreviewHandlerGuid = TShellPreviewHandlerGuids.Excel) then eventArgs.ForceGUIThread := true; // The following lines of code will force the loading of thumbnails for pdf files instead of using a preview handler. if LowerCase(ExtractFileExt(eventArgs.Path)) = '.pdf' then eventArgs.LoadThumbnail := true; // disable the Previewhandler for .eml and .jer files, since it displays a message to download the file. if (UpperCase(ExtractFileExt(eventArgs.Path)) = '.EML') or (UpperCase(ExtractFileExt(eventArgs.Path)) = '.JER') then eventArgs.PreviewHandlerGuid := TGuid.Empty; //the following uses a custom preview handler to view animated images with extension .WEBP. It uses a TSkAnimatedImage to show the file. if (Uppercase(ExtractFileExt(eventArgs.Path)) = '.WEBP') then begin eventArgs.CustomPreviewHandler := TAnimatedImagePreviewHandler.Create(); end;
|
Name |
Description |
|
Provide code that loads the file given in the event arguments. | |
|
Is called when the preview should be resized. | |
|
Code to unload the custom preview handler goes here. |