Transparent background in CImageList

I create a CImageList that I attach to a TreeCtrl. The imagelist consists of Icons that I load from different files on the harddrive. I want the background of the icons to be transparent in the treeview, how can I make that work? I have tried:
m_imageList.SetBkColor (CLR_NONE);
That doesn't work.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Try the following.

Derive Ur own class from CImageList.
Map WM_CTLCOLOR to that.


// Set background mode transparent

Try it out.
SlaskAuthor Commented:
I can't map WM_CTLCOLOR to CImageList since CImageList is derived from CObject and that makes it impossible, from what I can tell, to map it....
You have to set the ILD_TRANSPARENT flag for this purpose.
I used this in ImageList_DrawEx(...) while I was using OwnerDrawn ListCtrl.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

SetBkMode() affects only text, not anything else drawn with GDI.

..B ekiM

where <color> is the background color you need to be transparent

SetBkColor(RGB(0,0,0)) will remove all black pixels from image thus allowing transparent background
SetBkColor(RGB(192,192,192)) will remove all GRAY pixels from image and replace with background pixels .

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SlaskAuthor Commented:
Thank you....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.