J
JD
Hi,
I am reposting the following problem because I find a new clue that may lead
a solution. In the simple code below, I create a treeview control which has
"A" and "B" on its 1st level. Each of "A" and "B" has a child, "A's child"
and "B's child" respectively. The problem is that "A's child" always shows
an image as its parent "A" even though I specify I_IMAGECALLBACK for "A's
child", meaning no image at all. The problem exists only if I specify "Has
lines" and "Lines at root" at the same time for the tree control style. I
try many other combinations (including "has buttons") and all works fine. I
try both VS 2005 and 6.0 and both have the same behavior. Is it a MFC
limitation that if you want "Has lines" and "Lines at root" both, then you
has to specify images for all items?
Please help me because I have been wrestling with this supposed to be simple
stuff for several days. Any help is much appreciated.
JD
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_imgList.Create(IDB_BITMAP_AB, 16, 2, RGB(255, 0, 255));
int nCount = m_imgList.GetImageCount(); // make sure there are two images
m_treeCtrl.SetImageList(&m_imgList, TVSIL_NORMAL);
HTREEITEM hNo = m_treeCtrl.InsertItem(_T("A"), 0, 0);
HTREEITEM h = m_treeCtrl.InsertItem(_T("A's child"), I_IMAGECALLBACK,
I_IMAGECALLBACK, hNo);
HTREEITEM hYes = m_treeCtrl.InsertItem(_T("B"), 1, 1);
h = m_treeCtrl.InsertItem(_T("B's child"), I_IMAGECALLBACK,
I_IMAGECALLBACK,
hYes);
...
I am reposting the following problem because I find a new clue that may lead
a solution. In the simple code below, I create a treeview control which has
"A" and "B" on its 1st level. Each of "A" and "B" has a child, "A's child"
and "B's child" respectively. The problem is that "A's child" always shows
an image as its parent "A" even though I specify I_IMAGECALLBACK for "A's
child", meaning no image at all. The problem exists only if I specify "Has
lines" and "Lines at root" at the same time for the tree control style. I
try many other combinations (including "has buttons") and all works fine. I
try both VS 2005 and 6.0 and both have the same behavior. Is it a MFC
limitation that if you want "Has lines" and "Lines at root" both, then you
has to specify images for all items?
Please help me because I have been wrestling with this supposed to be simple
stuff for several days. Any help is much appreciated.
JD
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_imgList.Create(IDB_BITMAP_AB, 16, 2, RGB(255, 0, 255));
int nCount = m_imgList.GetImageCount(); // make sure there are two images
m_treeCtrl.SetImageList(&m_imgList, TVSIL_NORMAL);
HTREEITEM hNo = m_treeCtrl.InsertItem(_T("A"), 0, 0);
HTREEITEM h = m_treeCtrl.InsertItem(_T("A's child"), I_IMAGECALLBACK,
I_IMAGECALLBACK, hNo);
HTREEITEM hYes = m_treeCtrl.InsertItem(_T("B"), 1, 1);
h = m_treeCtrl.InsertItem(_T("B's child"), I_IMAGECALLBACK,
I_IMAGECALLBACK,
hYes);
...