Displaying Thumbnails
-
I am creating an app that closly resembles MS Windows Explorer. Thetrouble is, I have no idea how the thumbnail objects were created that represent image files. Also, what oblect are the thumbnails and filenames placed in? Mr. Mike
From what I have read somewhere... With your image item you call some method like, GetThumbnail or CreateThumbNail and Windwos actually stores these thumbnails and when another program calls GetThumbnail or whatever it is, it checks to see if a thumbnail is already present for that image. If so it returns that one, if not it creates a new one. I also read that there is no way of creating a new thumbnail once one is created, only way is to manually delete the thumbnail image from the disk. Because Windows may create a thumbnail for displaying in Explorer and then its too small for what you want so it stretches it in your app and it looks horrible. I have only read all this along time ago, never worked with any of it though. Thought this might be of some help to get you started. Look in the .Net class library for the System.Drawing.Imaging.Image class and see if a Get or Create Thumbnail method is some where there. Hope that helps.
-
From what I have read somewhere... With your image item you call some method like, GetThumbnail or CreateThumbNail and Windwos actually stores these thumbnails and when another program calls GetThumbnail or whatever it is, it checks to see if a thumbnail is already present for that image. If so it returns that one, if not it creates a new one. I also read that there is no way of creating a new thumbnail once one is created, only way is to manually delete the thumbnail image from the disk. Because Windows may create a thumbnail for displaying in Explorer and then its too small for what you want so it stretches it in your app and it looks horrible. I have only read all this along time ago, never worked with any of it though. Thought this might be of some help to get you started. Look in the .Net class library for the System.Drawing.Imaging.Image class and see if a Get or Create Thumbnail method is some where there. Hope that helps.
It's stored in a system image list, and there is a way to purge the list itself. Also, the method to which you're referring is
System.Drawing.Image.GetThumbnailImage
.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
I am creating an app that closly resembles MS Windows Explorer. Thetrouble is, I have no idea how the thumbnail objects were created that represent image files. Also, what oblect are the thumbnails and filenames placed in? Mr. Mike
This really is an application-specific problem. Explorer's ListView (the common control 6 ListVew32) uses a system image list and many, many other things to query files type handlers for a certain interface (
IThumbnailCapture
) which returns an image that it stores in a cache (in this case, a hidden system file named thumbs.db). For your application, you could do something similar, although using the default controls leave much to be desired (not everything from Windows' common controls is wrapped in the .NET equivalents). Get thumbnails for yourListViewItem
s, add them to theListView
'sLargeImageList
property, and then set the appropriateListViewItem
s'ImageIndex
property to the index in which the thumbnail was inserted. In effect, these become the icons for theListViewItem
s. Unfortunately, if you want the thumbnail view that Explorer boasts, it won't be an easy task. First, you must make sure your application is bound to common controls 6 (in .NET 1.1, callApplication.EnableVisualStyles
before callingApplication.Run
in your program's entry point,Main
), or use a manifest file (see my article list for an article that describes it). Then you'll have to P/Invoke lots of Win32 native functions and override a lot of functonality. Not fun. :( I hope at least I gave you some idea of what Explorer does for the functionality you want. Again, though, it's really up to you about how to do it since you control the code in your app.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----