🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: SHGetFileInfo and system image list

#16718
From: Nick B. Cassos
Date: Thu, 01 May 2003 10:26
34 lines
2012 bytes
On Thu, 1 May 2003 10:24:39 +0400, "Dmitry Mikhilov" <dm1@fromru.com>
wrote:

>Hello,
>
>I got weird problem when trying to show icons representing file types in an
>"explorer-like" list view (style is vsReport so small images are used, file
>icons are shown as StateImages)....

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: <18t1bv0lpjgqv1tblq09gh7u0j87hjtj2i@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3eb0bdcd@newsgroups.borland.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 03:43:00 PST
From: Nick B. Cassos <nbc@no_spam.ath.forthnet.gr>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: SHGetFileInfo and system image list
Date: Thu, 01 May 2003 13:26:21 +0300
Message-ID: <18t1bv0lpjgqv1tblq09gh7u0j87hjtj2i@4ax.com>
References: <3eb0bdcd@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 213.16.148.164
X-Trace: newsgroups.borland.com 1051784786 213.16.148.164 (1 May 2003 03:26:26 -0700)
Lines: 34
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail