Tree View Control state image list
I'm trying to implement a tree view in an MFC wizard property sheet that has
check boxes that can be dimmed. In order to do this, I've created an image
list that has the check boxes in each of their 4 possible combinations of
unchecked/checked and enabled/disabled (as well as a blank image at index 0).
However, when I set this image list as the tree view control's state image
list, all I see are blank images where the check boxes should be. (I use the
correct state indices when I add the various items. I'm using commctl32
version 5.80 and Visual Studio 2005, so according to the documentation, I
should be able to have a state image list without a main image list.
The tree control is set with the Check Boxes property set to TRUE. The
bitmap resource that I'm using is a 16-colour bitmap with a white background
that I want to appear as transparent. (I'm using ::LoadImage() and
CImageList::Add() instead of CImageList::Create() in the code, because I want
the greys in the bitmap (in the 'disabled' images) to map to the system 3D
colours.)
Sample code appears below:
class CMyPropPage : public CPropertyPage
{
.
.
.
CTreeCtl mMyTree;
.
.
.
}
BOOL CMyPropPage::OnInitDialog()
{
CImageList ImageList;
HBITMAP hBitmap;
HTREEITEM hParent, hTreeItem;
.
.
.
ImageList.Create(16, 16, ILC_COLOR4, 0, 5);
hBitmap = (HBITMAP)::LoadImage(theApp.hInstance,
MAKEINTRESOURCE(IDB_STATEIMG), IMAGE_BITMAP, 80, 16, LR_LOADMAP3DCOLORS);
ImageList.Add(CBitmap::FromHandle(hBitmap), RGB(255, 255, 255));
mMyTree.SetImageList(&ImageList, GVSIL_STATE);
.
.
.
hTreeItem = mMyTree.InsertItem(TVIF_STATE | TVIF_TEXT, _T("Item 1"), 0,
0, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK, 0, TVI_ROOT, TVI_LAST);
hTreeItem = mMyTree.InsertItem(TVIF_STATE | TVIF_TEXT, _T("Item 2"), 0,
0, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK, 0, TVI_ROOT, TVI_LAST);
hTreeItem = mMyTree.InsertItem(TVIF_STATE | TVIF_TEXT, _T("Item 3"), 0,
0, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK, 0, TVI_ROOT, TVI_LAST);
hParent = hTreeItem;
hTreeItem = mMyTree.InsertItem(TVIF_STATE | TVIF_TEXT, _T("Item 3.1"),
0, 0, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK, 0, hParent, TVI_LAST);
.
.
.
}
Can anybody tell me what I'm doing wrong? How do I get the check box images
to appear?