Article View: borland.public.cppbuilder.nativeapi
Article #4230Re: Getting SYS Icons
From: Remy Lebeau (TeamB)
Date: Wed, 08 Mar 2006 19:50
Date: Wed, 08 Mar 2006 19:50
40 lines
2464 bytes
2464 bytes
"poojo hackma" <poojo.com/mail> wrote in message
news:440ef041$1@newsgroups.borland.com...
> It was simple enough to copy the technique, but I want to extend it
> to files *not* located on my PC (i.e. files over a network).
The demo code you posted is using ITEMIDLIST values to keep track of local
files only, and then passing those ITEMIDLISTs to SHGetFileInfo() to get the
appropriate shell image list index when needed. To do what you are asking,
you would first need to update the code to detect virtual items so that you
can specify filenames instead of ITEMIDLISTs. When calling SHGetFileInfo()
for a filename, specify the SHGFI_USEFILEATTRIBUTES flag so that a physical
file is not needed, and remove the SHGFI_PIDL flag. That way,
SHGetFileInfo() returns the index for the icon belonging to the specified
file extension. For example:
int __fastcall GetShellImage(const AnsiString &FileName, bool Large,
bool Open)
{
SHFILEINFO FileInfo = {0};
int Flags = SHGFI_SYSICONINDEX | SHGFI_ICON | SHGFI_USEATTRIBUTES;
if( Open )
Flags |= SHGFI_OPENICON;
if( Large )
Flags |= SHGFI_LARGEICON;
else
Flags |= SHGFI_SMALLICON;
::SHGetFileInfo(FileName.c_str(), FILE_ATTRIBUTE_NORMAL, &FileInfo,
sizeof(FileInfo), Flags);
return FileInfo.iIcon;
}
> I don't understand what to assign the fileInfo.iIcon parameter to
> (TListView->Items->ImageIndex = fileInfo.iIcon?)
Yes, you assign the iCon value to the TListItem::ImageIndex property.
Gambit
Technical Details
Message-ID:
<440f3555$3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<440ef041$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9456c511753bafd3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <440ef041$1@newsgroups.borland.com> Subject: Re: Getting SYS Icons Date: Wed, 8 Mar 2006 11:50:48 -0800 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <440f3555$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1141847381 68.69.17.41 (8 Mar 2006 11:49:41 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail