Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / MFC

How to use 32 bit icons in CTreeCtrl

2.96/5 (24 votes)
6 Jul 2006CPOL 1   3.8K  
This article explains how to use 32 bit icons in a CTreeCtrl.

Introduction

This article explains how to use high colored icons with the common control, CTreeCtrl.

This is done in just four lines of code!!!

Sample image

How To

In your dialog class header, just add two attributes:

C++
CImageList m_imageList; //image list used by the tree
CBitmap m_bitmap; //bitmap witch loads 32bits bitmap

At the end of InitDialog:

C++
// Create a 32bits ImageList
m_imageList.Create (16, 16, ILC_COLOR32 , 1,1);

//Add the bitmap to the ImageList
m_bitmap.LoadBitmap(IDB_BITMAP_HIGHCOLOR);
m_imageList.Add(&m_bitmap, RGB(255,0,255));

//Manage your tree items......
m_tree.SetImageList (&m_imageList, TVSIL_NORMAL);
m_tree.InsertItem("RootItem",0,0,TVI_ROOT);

This is a very easy way to making a good rendering with VC++ 6.0.

That's all !!!!

License

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