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);沒有用。。
CTreeCtrl::SetItemState(lhItem, 0, TVIS_SELECTED);