|
-
February 17th, 2012, 10:58 AM
#1
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?
-
February 17th, 2012, 11:25 AM
#2
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?
Victor Nijegorodov
-
February 17th, 2012, 11:32 AM
#3
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!!...
-
February 17th, 2012, 11:54 AM
#4
Re: SelectedItem Icon differs with declaration.
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.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|