65.9K
CodeProject is changing. Read more.
Home

How to use 32 bit icons in CTreeCtrl

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.96/5 (24 votes)

Jul 7, 2006

CPOL
viewsIcon

104133

downloadIcon

3767

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:

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

At the end of InitDialog:

// 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 !!!!