🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Assigning Icon from ExtractIconEx without leaks

#179
From: Bob Gonder
Date: Tue, 01 Jul 2008 14:38
34 lines
1859 bytes
Mike Collins wrote:

>HICON hIconSmall;
>ExtractIconEx(sObject.c_str(), 0, NULL, &hIconSmall, 1);
>if (hIconSmall)
>{
>   Image->Picture->Icon->Handle = hIconSmall;
>   ::DestroyIcon(hIconSmall);
>}
>- however, as soon as i call DestroyIcon - the image is lost.

Destroy the Image->Picture->Icon->Handle instead,
when you are through with it.

>if (hIconSmall)
>{
>       TIcon *icoSmall = new TIcon;
>       icoSmall->Handle = hIconSmall;
>       Image->Height = 16;
>       Image->Width = 16;
>       Image->Canvas->Draw(0, 0, icoSmall);
>       delete icoSmall;
>       ::DestroyIcon(hIconSmall);
>}
>- this works and doesn't seem to have any resource leaks but the image is 
>not painted transparent - i have a white background displayed.  I've tried 
>setting the Transparent property of the TImage but it doesn't make any 
>difference.

Is that a typo?
TIcon needs the transparent property.
I would think it would be
	icoSmall->Transparent = TRUE;
	icoSmall->SetSize(16,16);
Technical Details
Message-ID: <9mfk64t6o1jol950ah8qm1ghr2kao5ffmo@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <486a1911@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,dea519f40adb32bd
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <none@nowhere.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Assigning Icon from ExtractIconEx without leaks
Date: Tue, 01 Jul 2008 07:38:55 -0700
Message-ID: <9mfk64t6o1jol950ah8qm1ghr2kao5ffmo@4ax.com>
References: <486a1911@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: 67.77.146.152
X-Trace: newsgroups.borland.com 1214923132 67.77.146.152 (1 Jul 2008 07:38:52 -0700)
Lines: 36
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail