🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16720

Re: SHGetFileInfo and system image list

#16720
From: Dmitry Mikhilov
Date: Thu, 01 May 2003 11:22
40 lines
2272 bytes
Thank you, Nick, but nothing has changed after applying your sample.

...I wonder, is it correct that I obtain the handle of the system image list
and assign it to TListView->StateImages->Handle only once at startup of my
application? Can the handle of the system image list  be dynamically changed
by Windows somehow and thus the old handle becomes invalid?

NB. There are only files whose icons I try to show,  so there are no folders
at all.

Dmitry


"Nick B. Cassos" <nbc@no_spam.ath.forthnet.gr> wrote:
news:18t1bv0lpjgqv1tblq09gh7u0j87hjtj2i@4ax.com...
> Your first call (for obtaining the image list handle) should be:
>
> DWORD ImageHandle = SHGetFileInfo("", 0, &info, sizeof(info),
> SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
>
> The next call (for obtaining the icon index):
>
> SHGetFileInfo(AFileItem->Name.c_str(), 0, &info, sizeof(info),
> SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);
>
> AListItem->ImageIndex =  IsDir() ? FDirIconIdx : info.iIcon;
>
> You should cache the index for a folder as follows:
>
>  char   Buffer[MAX_PATH];
>  ::GetTempPath(MAX_PATH , Buffer);
>  SHFILEINFO    info;
>  SHGetFileInfo(Buffer, 0, &info, sizeof(info), SHGFI_SMALLICON |
> SHGFI_SYSICONINDEX);
>  FDirIconIdx = info.iIcon;
>
>
> -- 
>
> Nick B. Cassos
Technical Details
Message-ID: <3eb10399@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3eb0bdcd@newsgroups.borland.com> <18t1bv0lpjgqv1tblq09gh7u0j87hjtj2i@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,577f7a686a96c6b6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-01 04:28:27 PST
From: "Dmitry Mikhilov" <dm1@fromru.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3eb0bdcd@newsgroups.borland.com> <18t1bv0lpjgqv1tblq09gh7u0j87hjtj2i@4ax.com>
Subject: Re: SHGetFileInfo and system image list
Date: Thu, 1 May 2003 15:22:27 +0400
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 195.131.110.226
Message-ID: <3eb10399@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1051788185 195.131.110.226 (1 May 2003 04:23:05 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail