I have written a code of the TreeView Control by a blog article. I am trying to add icons to list items. But icons are no rendered. I have a next code:
void CLeftView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
// TODO: Add items by GetTreeCtrl().
HICON hi = NULL;
hi = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON1));
if (hi != NULL)
{
MessageBox(NULL, L"resource1");
}
else MessageBox(NULL, L"Not resource1");
HICON lo = NULL;
lo = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ICON2));
if (lo != NULL)
{
MessageBox(NULL, L"resource2");
}
else MessageBox(NULL, L"Not resource2");
CImageList m_tree_imglist;
CTreeCtrl & tc = CTreeView::GetTreeCtrl();
m_tree_imglist.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 2);
m_tree_imglist.Add(hi);
m_tree_imglist.Add(lo);
tc.SetImageList(&m_tree_imglist, TVSIL_NORMAL);
HTREEITEM hItem;
hItem = tc.InsertItem(L"Fonts", 0, 0, TVI_ROOT);
tc.InsertItem(L"Arial", 0, 0, hItem);
tc.InsertItem(L"Times", 0, 0, hItem);
tc.Expand(hItem, TVE_EXPAND);
}
Icons have added to resource's files. There's do I have a bug? I have message boxes with a next text: "resource1", "resource2".