Click here to Skip to main content
Click here to Skip to main content

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

Introduction

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.

History

  • 02/27/2004, Initial release.

License

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

Share

About the Author

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

Comments and Discussions

 
GeneralWorks, thank you for your effort Pinmemberxpmule25-Feb-11 21:29 
General1 Pinmemberwslong17-Aug-09 20:57 
thank you so much
GeneralGreat stuff! PinmemberBernd Giesen20-Jul-09 23:24 
GeneralThanks! PinmemberDarkWeaver545521-Feb-07 10:37 
GeneralCan't make it work with original TreePropsheet Pinmemberstokos18-Aug-05 5:13 
GeneralRe: Can't make it work with original TreePropsheet PinmemberYves Tkaczyk18-Aug-05 12:53 
GeneralRe: Can't make it work with original TreePropsheet Pinmemberstokos19-Aug-05 1:15 
GeneralRe: Can't make it work with original TreePropsheet Pinmemberstokos24-Aug-05 23:21 
GeneralFix for --> Can't make it work with original TreePropsheet PinmemberWarren D Stevens13-Mar-06 7:13 
GeneralYou can solve it this way Pinmembertestgames16-May-06 6:27 
QuestionRe: Can't make it work with original TreePropsheet Pinmembersankking26-Nov-07 20:34 
QuestionHow to control the CPropertySheet tab colours? PinmemberShraddhan15-Jun-05 6:57 
AnswerRe: How to control the CPropertySheet tab colours? PinmemberYves Tkaczyk15-Jun-05 14:32 
GeneralNo high color in W2K Pinmemberckskodadf3-Nov-04 12:04 
GeneralRe: No high color in W2K PinmemberYves Tkaczyk3-Nov-04 14:17 
GeneralRe: No high color in W2K Pinmemberckskodadf4-Nov-04 3:03 
GeneralUnicode Pinmembermkg22-Oct-04 8:37 
GeneralJust the tab control Pinmembersammyc17-Jun-04 19:38 
GeneralRe: Just the tab control PinmemberTariq87819-Jul-04 2:00 
GeneralRe: Just the tab control PinmemberSuvendra2-Jan-05 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.8.141015.1 | Last Updated 27 Feb 2004
Article Copyright 2004 by Yves Tkaczyk
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid