Create Windows Apps with Explorer Previews
Save time with our ShellBrowser Components
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 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:
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:
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:
If 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:
Let us show you how it’s done. The following code loads thumbnails for wmf files:
var lPicture: TPicture;
if LowerCase(ExtractFileExt(Path)) = '.wmf' then begin
lPicture := TPicture.Create;
Bitmap := TBitmap.Create;
Bitmap.PixelFormat := pf24bit;
Bitmap.Width := Width;
Bitmap.Height := Height;
else if IsDrive(Path) then begin
Bitmap := TJamThumbnailExtractor.GetThumbnailBitmap(TJamItemIdList.Create(Path), Width, Height, true);
Learn more in our ShellBrowser online manual.
Previews – that’s what make your users happy!
While thumbnails are a very common way to get a small impression of what’s inside a file without the need to fully open it up, previews go even further:
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.
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.
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.
Looking for more information on the native Windows functionalities? Then take a look inside the Windows technical documentation.
This article was first published on the Embarcadero Blog. Check it out.
Want to always stay up to date? Subscribe to our newsletter now!
Do you like what you've just read, have new ideas or feedback? Visit our contact form and let us know your thoughts!