🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
1 messages
1 total messages Started by Renald Yazmir Thu, 05 Jun 2008 13:28
LoadImage() fails
#309
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads