![ShellBrowserBeiträgeBannerEN | Embarcadero RAD Studio Delphi C++Builder Blogs shellbrowser beitrage banner en 3](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/04/ShellBrowser-Beitrage-Banner-EN-6401159-1448693.jpg?resize=1140%2C630&ssl=1)
Table of Contents
The pain of finding the right file
Let’s be honest: Searching for files in the file explorer or on your desktop can be very annoying. Especially if you are looking for a certain picture of – let’s say – your last holiday trip to Italy. Luckily, previews are a thing for a while now!
The busy software user expects your program to present him or her a little preview of the file content when selecting an item: Imagine users scrolling through a directory full of Excel files, for example. Do you expect them to open each one individually to check if it’s the right table they are looking for? No, not really. You want your users to feel more comfortable because your software offers a quick preview of document contents in the tiny window on the right side. Does this sound good to you?
Comfort features are a must have for professional software, but easier said than done. Programming your own file preview feature can be very time consuming and expensive. Especially if you are running a smaller project and cannot rely on shared code. An alternative to building your own complex functionalities is reusing the native Windows functionalities used in the Windows file explorer. So, is there any way to go back to the native Windows functionalities? This is where our ShellBrowser comes in: We offer you developer components for creating file thumbnails and previews with an ease, enabling the use of native Windows functionality. Let us take a closer look!
Thumbnails – what are those again?
First, we should make clear the differences between a thumbnail and an icon. An icon is a pictogram – or to put it more simply: a tiny picture – that represents a data file in your file system or on the desktop. On Windows, most file types have their own icons alongside different file extensions. Let us give you an example:
![Examples for icons | Embarcadero RAD Studio Delphi C++Builder Blogs Examples for icons](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/06/Beispiel-fur-Icons-1338682.png?resize=750%2C392&ssl=1)
Examples for icons
A thumbnail, on the other hand, represents files not by their file type but by their individual contents. Usually in modern software, image files are represented by a small version of the image itself and not by an icon. There is a trend towards showing documents like Office files or PDFs as thumbnails, too. Here’s an example:
![Examples for thumbnails | Embarcadero RAD Studio Delphi C++Builder Blogs Examples for thumbnails](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/06/Beispiel-fur-Thumbnails-6180487.png?resize=750%2C392&ssl=1)
Examples for thumbnails
How can ShellBrowser help?
With ShellBrowser Delphi Components, we offer a variety of components that use the native “ThumbnailProvider” functionality of Windows. Embedded in RAD Studio, ShellBrowser lets you use thumbnails for image files in your software very easily. Depending on individual file or program configurations, you can also let previews of MS-Office documents, PDFs and many more be shown. Our ShellListView components help you to toggle the thumbnail view on and off:
Toggle between icons and thumbnailsIf you only want to present thumbnails for a single file at a time, you may choose the TJamThumbnailImage.
Another key benefit of using the ShellBrowser components is the asynchronous loading of thumbnails. Doing so, we ensure responsiveness and stability of your software – even if the loading process may take some time, especially when displaying thumbnails in very large folders, the usability of your software is not affected.
Thumbnails even if the system can’t provide one
Although thumbnails are an absolute standard for software usability nowadays, even the Windows Explorer does not support some file types like .WMF. Anyway, ShellBrowser does the trick with its ThumbnailNotAvailable Event Handler: Choose your own thumbnails instead of falling back on icons:
![WMF example | Embarcadero RAD Studio Delphi C++Builder Blogs Example for thumbnails for WMF files](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/06/JamExplorerWithWMF-3726080.png?resize=750%2C392&ssl=1)
Example for thumbnails for WMF files
Let us show you how it’s done. The following code loads thumbnails for .WMF files:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
procedure TMainForm.ThumbnailUnavailable(const Path: string; Width, Height: Integer; out Bitmap: TBitmap); var lPicture: TPicture; begin if LowerCase(ExtractFileExt(Path)) = '.wmf' then begin lPicture := TPicture.Create; try lPicture.LoadFromFile(Path); Bitmap := TBitmap.Create; Bitmap.PixelFormat := pf24bit; Bitmap.Width := Width; Bitmap.Height := Height; Bitmap.Canvas.Lock; Bitmap.Canvas.StretchDraw(Rect(0,0,Width,Height), lPicture.Graphic); Bitmap.Canvas.Unlock; finally lPicture.Free; end; end else if IsDrive(Path) then begin Bitmap := TJamThumbnailExtractor.GetThumbnailBitmap(TJamItemIdList.Create(Path), Width, Height, true); end; end; |
Learn more in our ShellBrowser online manual.
Previews – that’s what make your users happy!
Previews allow your users to interact with the file contents using a handy preview window. They get to read Word documents without loading up Word in full screen or can scan through an Excel table with an ease. It’s even possible to browse through PDF documents and zoom in and out if there is the need to. In other words: The preview feature lets your users really save time and nerves.
![Content preview | Embarcadero RAD Studio Delphi C++Builder Blogs Preview of file contents](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/06/Preview-Feature-1611364.png?resize=750%2C392&ssl=1)
Preview of file contents
ShellBrowser uses the native PreviewHandlers which are registered and integrated inside the Windows system. Doing so, it automatically detects if the selected file supports previews and if not, it jumps back to using a thumbnail instead – that’s because inside the TJamFilePreview the older TJamThumbnailImage is integrated. Also, it will automatically detect textual files, and use the Text PreviewHandler even if it is not registered with the respective file type.
A few words on configuration options of your preview
You can finetune the working of the TJamFilePreview by implementing the “OnLoadPreview” event. Here you can decide whether to prefer the thumbnail over the installed PreviewHandler or you may choose a different PreviewHandler than the one that is registered in the Windows system for the respective file type. You can also use an existing PreviewHandler to cover file types that wouldn’t provide a preview otherwise.
Finally, the “TDetailsPane” component contains the TJamFilePreview, but also the most common file properties, so users get a good overview on the file at a glance. All controls presented work fluently with other ShellBrowser controls – by assigning a TJamShellLink they will synchronize automatically with the selection of e.g. a TJamShellList.
![Details pane | Embarcadero RAD Studio Delphi C++Builder Blogs Detailled details pane](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/06/Details-Pane-8762340.png?resize=750%2C392&ssl=1)
Detailled details pane
At the same time it needs to be said that as both the TJamFilePreview and the TJamThumbnailImage are built around native Windows functionality: They implicitly use the shell extensions like ThumbnailProviders and PreviewHandlers installed in the system. That means not all aspects of the previews can be varied due to technical limitations.
Are you eager to try it out yourself? We offer a free trial version of ShellBrowser Delphi Components for 30 days. Visit our website to check it out!
Looking for more information on the native Windows functionalities? Then take a look inside the Windows technical documentation.
This article is part of a series introducing the ShellBrowser Delphi Components of JAM Software. Check out our last post on the Embarcadero Blog.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition