为什么ctreectrl在界面上不能展开??
qass 2005-07-29 03:06:54 BOOL CDepartsel::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//load dep info
dep.load_dep();
//add node
m_treeImageList.Create(16,16,FALSE,1,0); //create CImageList
//load ICON resource
HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
m_treeImageList.Add(hIcon); //add ICON to CImageList
//associate CImageList with Tree
m_tree.SetImageList(&m_treeImageList, LVSIL_NORMAL);
m_root = m_tree.InsertItem("Department:"); //add node
//call AddtoTree()ㄛadd all info to Tree
AddtoTree(m_root, 0);
m_tree.Expand(m_root, TVE_EXPAND); //expand root
//select root
m_tree.SelectItem(m_root);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDepartsel::AddtoTree(HTREEITEM m_node, int depid)
{
//add to treeview by recursion
int i;
HTREEITEM m_child;
//search one to treectrl if satisfy from dep one by one
for(i=0; i<dep.a_depid.GetSize(); i++)
{
//*** search for depid from a_depid
//*** hint the depid is the root node,add it to treectrl as m_child
//*** call SetItemData(),
//*** regard new node as root,recursion call AddtoTree()
if (depid == atoi(dep.a_depid.GetAt(i)))
{
m_child = m_tree.InsertItem(dep.a_depname.GetAt(i), m_node);
m_tree.SetItemData(m_child, atol(dep.a_depid.GetAt(i)));
AddtoTree(m_child, atoi(dep.a_depid.GetAt(i)));
}
}
}
void CDepartsel::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
是什么错误导致界面上的treeview无法展开呢,编译的时候,没有任何错误啊????
高手救救!!!!!