现在有一个TreeView,在设计时是空的,所有结点和子节点都是运行时添加的.
当我下次打开这个程序的时候,我想看到上次保存的节点信息?
请问如何解决这个问题? 添加节点部分代码如下:
如果有想看源程序的人可以加我的msn:libkorea@hotmail.com
void CTreeControlDlg::OnButtonInsert()
{
// TODO: Add your control notification handler code here
TV_INSERTSTRUCT tvStruct;
UpdateData(TRUE);
if (!m_strText.IsEmpty() )
{
tvStruct.hParent = m_hSelectedNode;
tvStruct.hInsertAfter = TVI_LAST;
tvStruct.item.mask = TVIF_TEXT;
tvStruct.item.pszText = (LPTSTR)(LPCSTR)m_strText;
m_treeControl.InsertItem(&tvStruct);
m_treeControl.Expand(m_hSelectedNode,TVE_EXPAND);
}
else
AfxMessageBox("Please input the FTP!");
m_strText.Empty();
UpdateData(FALSE);
}
初始化代码如下:
BOOL CTreeControlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
TV_INSERTSTRUCT tvStruct;
tvStruct.hParent = 0;
tvStruct.hInsertAfter = TVI_LAST;
tvStruct.item.mask = TVIF_TEXT;
tvStruct.item.pszText = "Input FTP";
m_hRoot = m_treeControl.InsertItem(&tvStruct);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}