Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Grayed Icons in a Tree

Posted on 2003-03-12
Medium Priority
Last Modified: 2013-11-20
How do you gray out icons in a tree view?  I'm trying to use overlay but I'm pretty confused.  Is overlay the normal method?  I figured I could just create a second version of every icon in grayscale but I'm pretty sure that isn't the proper way.

Right now I have
CImageList il;
CBitmap tree,overlay;
il.Create(16,16, ILC_COLOR4 | ILC_MASK 0 ,64);
il.Add(&tree,&overlay); //by using this version of Add my images don't have transparent sections

Later on when I want to overlay the image I do this:

What else do I need to get this to work?
Question by:pim42
  • 3
  • 2
LVL 11

Accepted Solution

KurtVon earned 60 total points
ID: 8120513
If you want to replace the whole image, and overlay is probably not the way to go.  Try just putting all the images on one image list and calling SetItemImage() instead.

Also, the Add call you use is for image masks, not overlays, so the "overlay" bitmap is just used to computer the transparency effect of the icons.  Check here to see how overlays are used: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cimagelist.3a3a.setoverlayimage.asp

Author Comment

ID: 8123337
Well I just hand created gray scale images and put them in the image list. Based on certain criteria I get the color or gray image.  Is this they way it is supposed to be done?  It seems like a hack to me.  It makes my image file twice as big (though that is only like 8kb).
LVL 11

Expert Comment

ID: 8123475
There are tricks for creating a "disabled" style image from a normal image, but I don't know of any simple way to use these in an image list connected to a CListCtrl outside of using overlays.

Even using overlays the overlay image must be in the image list (in one of the first 15 spots, limiting you to only 15 overlays max).  So the only way it works is if your overlay is like the one in Explorer (go to details view and look at the selected item's icon).  In that the overlay is just the selected color merged 50%.

I don't remember seing it done any other way than those two.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 12

Expert Comment

ID: 8123626

 I like the idea of a second set of icons to represent that the item is not available.

 My 2c :)
LVL 11

Expert Comment

ID: 8128150
Takes the same amount of memory, increases the complexity (well, for Windows anyway . . . which is all the guys who wrote the code in the first place really cared about).


Author Comment

ID: 8128214
Alright well I'll just go with what I got.  I have more than 15 icons so overlays might not be a good option.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

580 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