🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

LoadImage() fails

#309
From: Renald Yazmir
Date: Thu, 05 Jun 2008 13:28
132 lines
3167 bytes
Hello



The function LoadImage() fails when it is called multiple times(around 3325 
times).

First I noticed this in my application where I have multiple windows and 
call LoadImage() many times. Then I made a simple test and result was the 
same. Here is the code:



void test(void)

{

            int i = 0;

            HIMAGELIST image_list = NULL;

            HICON hicon;

            int ret = 0;



    // Create the imagelist.

    image_list = ImageList_Create(

                                        14,

                                        14,

                                        ILC_COLOR32 | ILC_MASK,

                                        0,

                                        0);



            if (image_list == NULL)

                        return;



            for (i = 0; i < 10000; i++)

            {

                        hicon = (HICON)LoadImage(

                                    npw_hInstance,

                                    MAKEINTRESOURCE(PICT_TEXT),

                                    IMAGE_ICON,

                                    0,

                                    0,

                                    LR_CREATEDIBSECTION | LR_LOADTRANSPARENT

                                    );



                        if (hicon == NULL)

                        {

                                    return;

                        }

                        else

                        {

                                    DeleteObject (hicon);

                        }



                        ret = ImageList_AddIcon(image_list, hicon);



                        if (ret < -1)

                        {

                                    return;

                        }

            }





            ImageList_Destroy(image_list);



}





In the code above LoadImage() fails (hicon is NULL) when "i" equals to 3325.

The 32 bit icon "PICT_TEXT" has size 1 KB.



Any idea why  LoadImage() fails?



Thank you



Rony
Technical Details
Message-ID: <4847dc08$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,23b9287586994cbf,start
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Renald Yazmir" <renald@partmaker.com>
From: "Renald Yazmir" <renald@partmaker.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: LoadImage() fails
Date: Thu, 5 Jun 2008 08:28:56 -0500
Lines: 136
Organization: IMCS Inc
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 66.106.28.123
Message-ID: <4847dc08$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1212668936 66.106.28.123 (5 Jun 2008 05:28:56 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
X-Original-Bytes: 2975