?
Solved

Grayed Icons in a Tree

Posted on 2003-03-12
6
Medium Priority
?
642 Views
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;
tree.LoadBitmap(IDB_TREE);
overlay.LoadBitmap(IDB_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
il.SetOverlayImage(0,1);

Later on when I want to overlay the image I do this:
treeCtrl.SetItemState(current, INDEXTOOVERLAYMASK(1), TVIS_OVERLAYMASK);

What else do I need to get this to work?
0
Comment
Question by:pim42
[X]
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
  • 3
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
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
0
 

Author Comment

by:pim42
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).
0
 
LVL 11

Expert Comment

by:KurtVon
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.
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 12

Expert Comment

by:williamcampbell
ID: 8123626

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

 My 2c :)
0
 
LVL 11

Expert Comment

by:KurtVon
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).

0
 

Author Comment

by:pim42
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.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

752 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