Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Getting Icon of Files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian P. Hammer - 07 Jul 2006 17:37 GMT
All - How can I get an icon associated with a particular file extension and
then get the icon displayed in a picturebox?

I have an app with a picturebox.  The picturebox displays pictures and other
files stored in SQL. If the SQL data is an image, it displays the image but
if it is, say a word doc, it displays an image I created that says "Not an
Image".  I would like to display the icon associated with the particular
file type inspectead.  So, when a user adds a word doc, the icon is shown in
the picturebox or adobe or whatever else the user might save to the
database.

Better even yet, would be to load a preview of the document into the
picturebox, like Adobe does in the "thumbnail" view of a windos folder.

Thanks,
Brian
Bob Powell [MVP] - 07 Jul 2006 18:39 GMT
This is a shell function using the IExtractImage interface.

Google for this interface such as "IExtractImage +C#"

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> All - How can I get an icon associated with a particular file extension
> and then get the icon displayed in a picturebox?
[quoted text clipped - 12 lines]
> Thanks,
> Brian
Brian P. Hammer - 07 Jul 2006 20:14 GMT
Thanks Bob.

> This is a shell function using the IExtractImage interface.
>
[quoted text clipped - 16 lines]
>> Thanks,
>> Brian
Brian P. Hammer - 07 Jul 2006 21:35 GMT
Bob - Not exactly what I am looking for I think.  I have files stored in a
database.  Let's say the user views DB stored file 2 in the picturebox. I
want to look at the extension field and get the icon associated with it, not
a thumbnail.  If file 2 is a Word doc, I would expect to see the MSWord icon
appear.

Maybe I missed something in IExtractInage interface?!?  The couple sample
projects and google links don't do that.  They get a thumbnail of an image
file. I want to get the Icon associated with the type of file.  The file
extension value I save in my database as well.

Thanks,
Brian

> This is a shell function using the IExtractImage interface.
>
[quoted text clipped - 16 lines]
>> Thanks,
>> Brian
Michael Phillips, Jr. - 07 Jul 2006 22:18 GMT
Use SHGetFileInfo with the SHGFI_ICON flag to retrieve a handle to the icon
associated with the file.

> All - How can I get an icon associated with a particular file extension
> and then get the icon displayed in a picturebox?
[quoted text clipped - 12 lines]
> Thanks,
> Brian
Brian P. Hammer - 08 Jul 2006 00:30 GMT
Thanks...  That is what I am looking for.

> Use SHGetFileInfo with the SHGFI_ICON flag to retrieve a handle to the
> icon associated with the file.
[quoted text clipped - 15 lines]
>> Thanks,
>> Brian

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.