How to add icon/bitmap in CImageList

Posted on 2003-02-25
Medium Priority
Last Modified: 2013-11-20
Hi, I would like to know if it is possible to add a icon in a CImageList dynamically. I would like to give a path for a bitmap or an icon and it would add this in a CImageList dynamically. How can I do so. Let's say the CImageList is imagelist, and the path is strPath.

Thank for replies, for further explanation just ask
Question by:mnault
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8039795

just add the following code

// The pointer to my image list.
CImageList* pmyImageList;

// Add my icons.

// Add my bitmap, make all black pixels transparent.
CBitmap bm;

pmyImageList->Add(&bm, RGB(0, 0, 0));

Author Comment

ID: 8049406
This does not work, unless you explain me how to define IDI_ICON1 to be a icon from any path besides beind predefined in the ressources. What I want is be able to take any image for the disk no matter what are the image in the ressources. The icons I might add will not be in the ressource at the compilation. Is it possible to add a ressource dynamically, from a icon/image file.

Accepted Solution

abdo81 earned 200 total points
ID: 8090902
CImageList* pmyImageList;

//first load the image
HANDLE hImage = LoadImage(NULL, strPath, IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE);
CBitmap* Bmp = CBitmap::FromHandle(hImage);
pmyImageList->Add(&Bmp, RGB(0, 0, 0));

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question