Article View: borland.public.cppbuilder.nativeapi
Article #832Re: Get the icon by using "SHGetFileInfo"...
From: remmurds
Date: Sun, 02 Dec 2007 23:40
Date: Sun, 02 Dec 2007 23:40
50 lines
2392 bytes
2392 bytes
"Asger Joergensen" <junk@Asger-P.dk> ���g��l��s�D:MPG.21bd27055e96426f989930@newsgroups.borland.com...
>
> Hi remmurds
>
> Do You check if the the handle is different from NULL ?
>
> According to the helpfile SHGFI_ICON is the one
> that will retrieve the handle to the icon the other
> SHGFI_LARGEICON go for a specific size and You don't
> need the index.
>
> This would be my suggestion:
>
> DWORD Res = SHGetFileInfo(FileName.c_str(), 0, &info, sizeof(info),
> SHGFI_ICON);
>
> if( ! Res){// GetLastError}
>
> if(info.hIcon)
> {
>
> if( ! DrawIconEx(ImageIco->Canvas->Handle, 0, 0, info.hIcon, 48, 48, 0, 0,
> DI_NORMAL) )
> {// GetLastError}
> }
>
> by the way what is ImageIco ?
> is it a TImage ?
> Have You remembered to set the size of ImageIco ?
>
> Kind regards
> Asger
Oh, sorry about that.
I forgot to explain that ImageIco is a TImage component :)
The size of ImageIcon is 48*48, the "Transparent" and "Stretch" property is
false;
Now I can draw the icon with this codes:
SHGetFileInfo(FileName.c_str(), 0, &info, sizeof(info), SHGFI_ICON);
DrawIconEx(ImageIco->Canvas->Handle, 0, 0, info.hIcon, 48, 48, 0, 0,
DI_NORMAL);
Mmm...but it looks like a smaller picture "zoom out" to 48*48 with "Mosaic",
even the original icon is 48*48(I made it for testing).
I will keep trying. Thank you for your suggestion : )
Technical Details
Message-ID:
<47534270@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4751fbc8$1@newsgroups.borland.com> <MPG.21bd0b1963f2bda698992f@newsgroups.borland.com> <4752fc27$1@newsgroups.borland.com> <MPG.21bd27055e96426f989930@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bee658860984a9b7 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII From: "remmurds" <remmurds.bbs@ptt.cc> Newsgroups: borland.public.cppbuilder.nativeapi References: <4751fbc8$1@newsgroups.borland.com> <MPG.21bd0b1963f2bda698992f@newsgroups.borland.com> <4752fc27$1@newsgroups.borland.com> <MPG.21bd27055e96426f989930@newsgroups.borland.com> Subject: Re: Get the icon by using "SHGetFileInfo"... Date: Mon, 3 Dec 2007 07:40:23 +0800 Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.3959 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 140.130.34.19 Message-ID: <47534270@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1196638832 140.130.34.19 (2 Dec 2007 15:40:32 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail