void TreeView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
TVINSERTSTRUCT ti = { 0 };
HTREEITEM hParent, Parent;
ptheTree = &GetTreeCtrl();
ptheTree->ModifyStyle(0, TVS_HASLINES | TVS_EDITLABELS);
//TreeView* m_pMyView = (TreeView*)m_wndSplitter.GetPane(0, 0);
HIMAGELIST himl; //加入图标
himl = ImageList_Create(27, 27, ILC_COLOR24, 1, 12);
ImageList_Add(himl, LoadBitmap(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_BITMAP10)), NULL);
SendMessage(TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)himl);
ti.item.mask = TVIF_TEXT | TCIF_IMAGE | TVIF_SELECTEDIMAGE;
ti.item.iImage = 2;
ti.item.iSelectedImage = 2;
ti.item.pszText = _T("默认文件夹");
ti.hParent = NULL;
ti.hInsertAfter = TVI_ROOT;
Parent = hParent = (HTREEITEM)SendMessage(TVM_INSERTITEM, 0, (LPARAM)&ti);
ti.hParent = hParent;
ti.hInsertAfter = TVI_LAST;//TVI_LAST表示节点添加在最后
ti.item.iImage = 0;
ti.item.iSelectedImage = 0;
ti.item.pszText = _T("默认笔记本");
hParent = (HTREEITEM)SendMessage(TVM_INSERTITEM, 0, (LPARAM)&ti);
ti.item.iImage = 3;
ti.item.iSelectedImage = 3;
ti.item.pszText = _T("回收站");
ti.hParent = NULL;
ti.hInsertAfter = TVI_ROOT;
Parent = hParent = (HTREEITEM)SendMessage(TVM_INSERTITEM, 0, (LPARAM)&ti);
// TODO: 在此添加专用代码和/或调用基类
}
是哪里初始化的不对吗?
我试过在初始化里放SelectItem(NULL);没有用。。