[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1585
  • Last Modified:

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.
Anyone???
0
Slask
Asked:
Slask
1 Solution
 
Vinayak KumbarSr Program ManagerCommented:
Hi,
Try the following.

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

there

// Set background mode transparent
pDC->SetBkMode(TRANSPARENT);

Try it out.
0
 
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....
0
 
V_BapatCommented:
You have to set the ILD_TRANSPARENT flag for this purpose.
I used this in ImageList_DrawEx(...) while I was using OwnerDrawn ListCtrl.
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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

..B ekiM
0
 
vachoohoCommented:
m_imageList.SetBkColor(<color>);

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

sample
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 .
0
 
SlaskAuthor Commented:
Thank you....
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now