Instant thumbnails in YOUR application! (sponsored by ThumbView)

Published November 26, 2005
Advertisement
After writing two samples on how to connect to ThumbView to use it to generate thumbnails for a C# application I got the superb question "Can't I just use whatever Windows is using?". ThumbView registers itself with Windows because Windows has support for shell-extensions such as thumbnail generators, then Explorer should be using something that's not bound to only one shell-extension. After some searching I found it! The Active X control ThumbCtl! Which resides in the webvw 1.0 Type Library component.

How to add it with Visual Studio C# Express 2005:

  1. Start a new project, Windows Application.

  2. In the Solution Explorer, right click on References and choose Add Reference.

  3. Go to the COM tab and scroll down to webvw 1.0 Type Library and press OK.

  4. In the Toolbox, right click anywhere and choose Choose Items.

  5. Go to the COM Components tab and scroll down to ThumbCtl Class. There are two, one has Language set to Unknown and the other to Independent. Unknown was the only one that worked for me, so tick that box and press OK.

  6. In the Toolbox, under Menus & Toolbars select ThumbCtl Class and draw out a rectangle on your form. This is where you'll see your thumbnail.


Done! To use it all you need to do is call the displayFile() function and passing it the filepath to your image!

If there's a registered thumbnail extractor (COM object: IExtractImage) then windows will call that and present the image on the area you drew out on your form. Here's a snip from my latest sample:
axThumbCtl.displayFile(openFileDialog1.FileName);

There's one thing though, I couldn't find a way to control how the thumbnail is generated so it'll stretch and deform your image however it feels like. =P

There is another function, haveThumbnail(), which oddly enough returns false whether or not you've called displayFile()... And the three properties (freeSpace, totalSpace, usedSpace) all return an empty string both before and after calling displayFile(). MSDN isn't helping since I only see ThumbCtl mentioned in other articles, but never explained in detail.

You can also use it in VB and C++. VB should be easy For C++, this MSDN article says: "To exploit this control in your MFC application, just add it to the dialog template. Microsoft Visual C++(R) will generate a wrapper class CThumbCtl. Next, define a member variable for it in your dialog class:"
If someone wants to write a sample and send it over I'll post it. =)

This sample and others are available on the ThumbView Project site, under Developers Corner. This particular sample is called "Thumbnail Viewer .NET 2.0 ActiveX".

Thanks to gwihlidal for the help.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement