ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
JamFilePreview.TJamFilePreview.OnLoadPreview

Occurs before the preview handler is loaded for the given file

Syntax
Pascal
property OnLoadPreview: TJamFilePreviewLoadPreviewEvent;

Use this event to control the PreviewHandler that is used to show the given file and to determine if a thumbnail of the file is acceptable. See TJamFilePreviewLoadPreviewEventArgs for details

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