SelectedItem Icon differs with declaration.
I use such code for add items to CTreeView
tvInsert.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
tvInsert.item.iImage = 1;
tvInsert.item.iSelectedImage = 1;
But when I run program in selection field I see other icon - #0, which differs with common state image...
What wrong in my actions?
Re: SelectedItem Icon differs with declaration.
Could you show some more lines? Because it is not clear what you do this this tvInsert object.
And, BTW, how many icons does the imagelist have?
Re: SelectedItem Icon differs with declaration.
VictorN,
3
Such I create ImageList:
CImageList *IL = new CImageList();
IL->Create(16,16,true,0,1);
IL->Add(AfxGetApp()->LoadIcon(IDI_ICON2));
IL->Add(AfxGetApp()->LoadIcon(IDI_ICON3));
IL->Add(AfxGetApp()->LoadIcon(IDI_ICON4));
pView->GetTreeCtrl().SetImageList(IL, TVSIL_NORMAL);
Such create item in CTreeView():
void CDirView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
start = true;
CTreeCtrl &TreeCtrl = GetTreeCtrl();
TVINSERTSTRUCT tvInsert;
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = NULL;
tvInsert.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
tvInsert.item.iImage = 1;
tvInsert.item.iSelectedImage = 1;
tvInsert.item.pszText = _T("C:");
HTREEITEM hRoot1 = TreeCtrl.InsertItem(&tvInsert);
tvInsert.item.pszText = _T("C:\\dipol\\iso");
HTREEITEM hRoot2 = TreeCtrl.InsertItem(&tvInsert);
tvInsert.item.pszText = _T("C:\\dipol\\apt");
HTREEITEM hRoot3 = TreeCtrl.InsertItem(&tvInsert);
tvInsert.hParent = hRoot1;
tvInsert.item.pszText = _T("t");
TreeCtrl.InsertItem(&tvInsert);
/* tvInsert.hParent = hRoot2;
Icons differs!!...
Re: SelectedItem Icon differs with declaration.
Quote:
IL->Create(16,16,true,0,1);
IL->Add(AfxGetApp()->LoadIcon(IDI_ICON2));
IL->Add(AfxGetApp()->LoadIcon(IDI_ICON3));
IL->Add(AfxGetApp()->LoadIcon(IDI_ICON4));
pView->GetTreeCtrl().SetImageList(IL, TVSIL_NORMAL);
I'd look in this direction. 16x16 is a small icon size, while TVSIL_NORMAL is used for large icons.