如何获取树形控件里选中项目的完整路径? 看看下面这两个,应该可以解决你的问题:http://www.codeproject.com/KB/tree/CFolderTreeCtrl.aspxhttp://www.codeproject.com/KB/tree/FileTreeCtrl.aspx 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 通过GetParentItem()和GetItemText()应该就可以了啊 GetParentItem()和GetItemText()0k 写程序时,遇到过这样的问题,自己想的方法,拿出来分享://得到当前选中结点的文件路径//参数hCurrItem: 当前选中结点CString CHostDirectoryDlg::GetFilePath(HTREEITEM hCurrItem){ HTREEITEM hParentItem; CString strFilePath; do { hParentItem = m_TreeCtrlDirectory.GetParentItem(hCurrItem); CString strTemp = m_TreeCtrlDirectory.GetItemText(hCurrItem); strFilePath.Insert(0, strTemp); //把当前结点的字符加到前面 strFilePath.Insert(0, "\\"); hCurrItem = hParentItem; }while(hParentItem != m_TreeCtrlDirectory.GetRootItem()); strFilePath = strFilePath.Right(strFilePath.GetLength() - 1); return strFilePath;} 像XP里"系统配置实用程序->启动"这种界面怎样做,即是表格里有复选框可供选择记录 我用在C学MFC吗? 怎样用VC实现在指定目录下生成一个.log或.txt文件? pCmdUI->SetCheck(1);不起作用!? 如何改变VC的默认存放目录 求在VC中实现windows资源管理器地址栏功能及其显示列表的代码或方法!急 为什么 CArchive 的ReadString()函数不能得到相关文件数据。 如何从非MFC dll内部获得该dll自身的句柄?来者有分!答问题者高分! 参数类型不对 如何使用系统的颜色选择对话框? MFC入口点函数困惑问题? 视频流的压缩存盘
0k
//参数hCurrItem: 当前选中结点
CString CHostDirectoryDlg::GetFilePath(HTREEITEM hCurrItem)
{
HTREEITEM hParentItem;
CString strFilePath;
do
{
hParentItem = m_TreeCtrlDirectory.GetParentItem(hCurrItem);
CString strTemp = m_TreeCtrlDirectory.GetItemText(hCurrItem);
strFilePath.Insert(0, strTemp); //把当前结点的字符加到前面
strFilePath.Insert(0, "\\");
hCurrItem = hParentItem;
}while(hParentItem != m_TreeCtrlDirectory.GetRootItem());
strFilePath = strFilePath.Right(strFilePath.GetLength() - 1);
return strFilePath;
}