Click here to Skip to main content
11,929,939 members (51,240 online)
Click here to Skip to main content
Add your own
alternative version


68 bookmarked

High color icons for CPropertySheet

, 26 Feb 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
Upgrading CPropertySheet tab control to display high color icons.

Sample Image - HighColorTab.png


I wanted to add icons on property pages for my current project. After selecting a few icons, that happened to be in 24 bits, and upgrading my application, I had the unpleasant surprise of seeing that the icons were displayed in only 16 colors.

I checked the Microsoft Knowledge Base and looked around for articles on the web discussing this issue but with no success. After investigating a little bit with CPropertySheet and its dependencies CTabCtrl and CImageList, I came up with the solution presented in this article.

Also note that the solution provided works with the excellent CTreePropSheet[^] control, which is what I was actually using.

Using the code

Using the code is very straightforward. You have to create a new class derived from CPropertySheet in order to override OnInitDialog. Include "HighColorTab.hpp" into the .cpp file of your new property sheet. In the body of OnInitDialog, add the following line:

HighColorTab::UpdateImageList( *this );

That's it: you are done! The demo project provides an example.

How does it work?

The code is pretty straightforward and is located in a single function in HighColorTab.hpp. The function does the following:

  • Get the tab control (CTabCtrl) from the provided property sheet (or object having a similar interface),
  • Create the replacement image list (CImageList) using the provided trait,
  • Populate the image list using the icon information stored in each property page,
  • Replace the image list,
  • Destroy the old image list.

The workflow is such that if anything goes wrong during the image list creation process, the property sheet remains unchanged.

The image list to be used can be customized via the trait provided to UpdateImageListFull. The trait must implement a method with the following signature:

static std::auto_ptr<CImageList> CreateImageList();

UpdateImageList uses a default trait that creates an image list with ILC_COLOR32. Do not forget to set ILC_MASK too or you will end up with a black background for the icons.


  • 02/27/2004, Initial release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Yves Tkaczyk
President ClearSquare Associates
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionMy vote of 5 Pin
Volynsky Alex12-Jan-15 2:55
professionalVolynsky Alex12-Jan-15 2:55 
AnswerRe: My vote of 5 Pin
Yves Tkaczyk12-Jan-15 6:01
memberYves Tkaczyk12-Jan-15 6:01 
GeneralRe: My vote of 5 Pin
Volynsky Alex12-Jan-15 11:23
professionalVolynsky Alex12-Jan-15 11:23 
GeneralWorks, thank you for your effort Pin
xpmule25-Feb-11 22:29
memberxpmule25-Feb-11 22:29 
General1 Pin
wslong17-Aug-09 21:57
memberwslong17-Aug-09 21:57 
GeneralGreat stuff! Pin
Bernd Giesen21-Jul-09 0:24
memberBernd Giesen21-Jul-09 0:24 
GeneralThanks! Pin
DarkWeaver545521-Feb-07 11:37
memberDarkWeaver545521-Feb-07 11:37 
GeneralCan't make it work with original TreePropsheet Pin
stokos18-Aug-05 6:13
memberstokos18-Aug-05 6:13 
GeneralRe: Can't make it work with original TreePropsheet Pin
Yves Tkaczyk18-Aug-05 13:53
memberYves Tkaczyk18-Aug-05 13:53 
GeneralRe: Can't make it work with original TreePropsheet Pin
stokos19-Aug-05 2:15
memberstokos19-Aug-05 2:15 
GeneralRe: Can't make it work with original TreePropsheet Pin
stokos25-Aug-05 0:21
memberstokos25-Aug-05 0:21 
GeneralFix for --> Can't make it work with original TreePropsheet Pin
Warren D Stevens13-Mar-06 8:13
memberWarren D Stevens13-Mar-06 8:13 
GeneralYou can solve it this way Pin
testgames16-May-06 7:27
membertestgames16-May-06 7:27 
QuestionRe: Can't make it work with original TreePropsheet Pin
sankking26-Nov-07 21:34
membersankking26-Nov-07 21:34 
QuestionHow to control the CPropertySheet tab colours? Pin
Shraddhan15-Jun-05 7:57
memberShraddhan15-Jun-05 7:57 
AnswerRe: How to control the CPropertySheet tab colours? Pin
Yves Tkaczyk15-Jun-05 15:32
memberYves Tkaczyk15-Jun-05 15:32 
GeneralNo high color in W2K Pin
ckskodadf3-Nov-04 13:04
memberckskodadf3-Nov-04 13:04 
I run the demo program under Windows XP and it worked great. However, when I tried it on several W2K machines, it displayed only 16 colors. I have set display effects to "Show icons using all possible colors" in display properties. I have also set the registry "HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\Shell Icon BPP" to 24 instead of 16. But none of them helps. If anyone knows how to solve the problem please let me know.


GeneralRe: No high color in W2K Pin
Yves Tkaczyk3-Nov-04 15:17
memberYves Tkaczyk3-Nov-04 15:17 
GeneralRe: No high color in W2K Pin
ckskodadf4-Nov-04 4:03
memberckskodadf4-Nov-04 4:03 
GeneralUnicode Pin
mkg22-Oct-04 9:37
membermkg22-Oct-04 9:37 
GeneralJust the tab control Pin
sammyc17-Jun-04 20:38
membersammyc17-Jun-04 20:38 
GeneralRe: Just the tab control Pin
Tariq87819-Jul-04 3:00
memberTariq87819-Jul-04 3:00 
GeneralRe: Just the tab control Pin
Suvendra2-Jan-05 7:32
memberSuvendra2-Jan-05 7:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 27 Feb 2004
Article Copyright 2004 by Yves Tkaczyk
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid