256 color (or true color) ImageLists showing up as 4-bit in CTreeCtrl?

I have a basicCDialog and aCTreeCtrl in it. When I try to attach icons into it, I run into slight trouble. Even though the bitmap is 256-color or true color, the icons always appear in fixed-palette 4-bit (16-color) in theCTreeCtrl.

The code is roughly this:

CImageList* imageList = new CImageList;
imageList->Create(IDB_ICONS, 24, 20, RGB(0xff, 0xff, 0xff));
tree->SetImageList(imageList, TVSIL_NORMAL);
tree->SetImageList(imageList, TVSIL_STATE);

What might be going wrong here? BothCreate() andSetImageList() giveS_OK.

I see there's another overload ofCImageList::Create() that takesILC_COLOR4,ILC_COLOR8,ILC_COLOR24 etc as an argument, but it seems that's only for creatingCImageLists from scratch without loading a ready bitmap into it. (When loading a bitmap, I gatherCreate() should figure out the color depth from the given image.)

Judging from
http://www.codeguru.com/Cpp/controls/imagelist/openfaq/article.php/c9045/
it may require a customCImageList to support true color at least in MSVC6.0, but surely 256 color should work without hassle?

This is MSVC7.1, XP SP 2.

[1818 byte] By [vherva] at [2007-12-16]
# 1

I tried almost everything.

Eventually, I found this:
http://www.codeguru.com/Cpp/controls/imagelist/article.php/c5501/

So apparently it should sth like:

CImageList* imageList = new CImageList;
CBitmap bm;
bm.LoadBitmap(IDB_NUDEIMAGE);
imageList->Create(24, 24, ILC_COLOR24 | ILC_MASK, 20, 20);
imageList->Add(&bm, RGB(255, 255, 255));
tree->SetImageList(imageList, TVSIL_NORMAL);
tree->SetImageList(imageList, TVSIL_STATE);

Shouldn't this quirk be documented somewhere? I lost quite a bit of time banging my head against the wall...

vherva at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...