Click here to Skip to main content
Licence CPOL
First Posted 26 Feb 2004
Views 89,465
Bookmarked 64 times

High color icons for CPropertySheet

By | 26 Feb 2004 | Article
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)

About the Author

Yves Tkaczyk

President
ClearSquare Associates
United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralWorks, thank you for your effort Pinmemberxpmule21:29 25 Feb '11  
General1 Pinmemberwslong20:57 17 Aug '09  
GeneralGreat stuff! PinmemberBernd Giesen23:24 20 Jul '09  
GeneralThanks! PinmemberDarkWeaver545510:37 21 Feb '07  
GeneralCan't make it work with original TreePropsheet Pinmemberstokos5:13 18 Aug '05  
GeneralRe: Can't make it work with original TreePropsheet PinmemberYves Tkaczyk12:53 18 Aug '05  
GeneralRe: Can't make it work with original TreePropsheet Pinmemberstokos1:15 19 Aug '05  
GeneralRe: Can't make it work with original TreePropsheet Pinmemberstokos23:21 24 Aug '05  
GeneralFix for --> Can't make it work with original TreePropsheet PinmemberWarren D Stevens7:13 13 Mar '06  
GeneralYou can solve it this way Pinmembertestgames6:27 16 May '06  
QuestionRe: Can't make it work with original TreePropsheet Pinmembersankking20:34 26 Nov '07  
QuestionHow to control the CPropertySheet tab colours? PinmemberShraddhan6:57 15 Jun '05  
AnswerRe: How to control the CPropertySheet tab colours? PinmemberYves Tkaczyk14:32 15 Jun '05  
GeneralNo high color in W2K Pinmemberckskodadf12:04 3 Nov '04  
GeneralRe: No high color in W2K PinmemberYves Tkaczyk14:17 3 Nov '04  
GeneralRe: No high color in W2K Pinmemberckskodadf3:03 4 Nov '04  
GeneralUnicode Pinmembermkg8:37 22 Oct '04  
GeneralJust the tab control Pinmembersammyc19:38 17 Jun '04  
GeneralRe: Just the tab control PinmemberTariq8782:00 19 Jul '04  
GeneralRe: Just the tab control PinmemberSuvendra6:32 2 Jan '05  

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.

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