🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

GDI and User Objects Overflow

#6726
From: Mark Jacobs
Date: Mon, 18 Apr 2005 14:38
23 lines
1815 bytes
I have an application that will display in a ListView a list of files, and 
their associated icons. As I scroll long lists of files up and down, the 
number of GDI and USER objects increases (according to task manager) until the 
GDI overflows at 10,000 objects. Why doesn't my code (or Windows) free up 
handles as it goes along? How can I reprogram this to avoid the overflow? Here 
is the code :-

     int jj,ci=ListView1->TopItem->Index,nr=ListView1->VisibleRowCount;
     int nof=ListView1->Items->Count; short icno=0; HICON asico;
     TListItem *li; char bf[MAXPATH+9];
     for (jj=0;jj<nr && ci+jj<nof;++jj)
     {
       li=ListView1->Items->Item[ci+jj];
       strcpy(bf,li->Caption.c_str());
       asico=ExtractAssociatedIcon(HInstance,bf,&icno); if (asico==NULL) continue;
 
DrawIconEx(Image1->Canvas->Handle,0,li->Position.y,asico,16,16,0,NULL,DI_NORMAL);
     }

TIA
-- 
Mark Jacobs
http://www.dkcomputing.co.uk
Technical Details
Message-ID: <4263c64a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c7f7d55dbf4194d8,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 18 Apr 2005 15:38:50 +0100
From: Mark Jacobs <http://www.jacobsm.com/mjmsg.htm?mj@critical>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: GDI and User Objects Overflow
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.144.157.8
Message-ID: <4263c64a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1113835082 81.144.157.8 (18 Apr 2005 07:38:02 -0800)
Lines: 23
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail