Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer peopleโ€™s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer peopleโ€™s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:44:18+00:00 2026-06-08T20:44:18+00:00

I’m confused because I cannot establish why my ImageList_Add call is failing. I know

  • 0

I’m confused because I cannot establish why my ImageList_Add call is failing. I know it must be something that I am doing wrong with the Image or maybe I’m calling it wrong but I have no idea how I can go about fixing it :S Any help you can offer would be appreciated! ๐Ÿ™‚

The code i’m using is below. I’m getting output on the console saying it couldn’t add to the image list. From the docs,ImageList_Add will return an indice of where in the imagelist it managed to add the image so -1 is returned if it cant.

Which is all well and good but I cannot find anywhere why/what causes the add to fail!

The code may have memory leaks, though at the moment,ive spent almost a day trying to figure out various issues with this so I just want to get it to work!

    HIMAGELIST imageList = ImageList_Create(20,20,ILC_COLOR16,1,2 );
if (imageList == NULL)
{
    printf("Error creating imagelist - dlg_create_dropdown_menu. Returning NULL\n");
    return NULL;
}

HBITMAP currentImage = (HBITMAP) LoadImage(NULL,"active_mdoe_icn.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
if (currentImage == NULL) 
{
   if (GetLastError()== 2) 
   {
       printf("File not found - dlg_create_dropdown_menu. Returning NULL.\n");
       return NULL;
   }
    printf("Error loading image from file - dlg_create_dropdown_menu. Returning NULL.\n");
    return NULL;
}
int imageIndex;
if ( (imageIndex = ImageList_Add(imageList,currentImage,NULL)) == -1 )
{
    printf("Error adding to the image list - dlg_create_dropdown_menu. Returning NULL.\n");
    return NULL;
}

Thanks all, any help would be greatly received! ๐Ÿ™‚

Could this be a problem with the actual image being corrupt? I’ve read about that in a few places.. Might just be my luck if i’m not doing anything daft ๐Ÿ™‚

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:44:19+00:00Added an answer on June 8, 2026 at 8:44 pm

    After much arguing with myself and windows I didnt figure out why the add was not working.

    Instead of trying using the imagelist I just load in each image one at a time at work with it that way. Not sure why I thought using the image list was better :s

    I was trying to load images into a dropdown menu I was creating but I found a better way of doing it. Which was using the MENUITEMINFO struct and specifying MIIM_BITMAP | MIIM_STRING as the two flags to fMask ๐Ÿ™‚ which mean I could have an image and an text in each menu item ๐Ÿ™‚

    Also image names with 0 underscores somehow makes it easier for windows to find lol

    Anyways, hope this helped someone ๐Ÿ™‚

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.