关于树形控件和组合框的问题~
2017-01-19 01:51
302 查看
想要的效果:已经可以在组合框一列列的添加驱动盘选择项,然后点击对应的驱动器后想在旁边的树形控件中相应盘里面的文件。
实际效果:问题1,点击c盘和d盘,出来A-Z的根节点,但是出不来相应的文件;问题2,点击e盘和f盘就出错说内存不能读。大家帮忙看看哪里出错了哈。辛苦大家啦~~
void CHView::OnSelchangeCombo1() //选择combobox的不同选项触发,m_combo为关联的组合框变量
{
// TODO: Add your control notification handler code here
int nIndex=m_combo.GetCurSel();
if(nIndex!=CB_ERR)
{
m_combo.GetLBText(nIndex,m_strMainDir);
PopulateTree();
}
}
void CHView::PopulateTree()、、m_treeFiles为关联的树形控件变量,
{
m_treeFiles.DeleteAllItems();
HTREEITEM hLetter[27];
for(int i='A';i<='Z';i++)
{
hLetter[i-'A']=m_treeFiles.InsertItem((TCHAR*)&i);
}
hLetter[26]=m_treeFiles.InsertItem("other");
HANDLE hFind;
WIN32_FIND_DATA dataFind;
BOOL bMoreFiles=TRUE;
CString strFile;
hFind=FindFirstFile(m_strMainDir+"\\*.*",&dataFind);
while(hFind!=INVALID_HANDLE_VALUE&&bMoreFiles==TRUE)
{
if(dataFind.dwFileAttributes==FILE_ATTRIBUTE_ARCHIVE)
{
int nChar=dataFind.cFileName[0];
if(islower(nChar))
nChar-=32;
if(isalpha(nChar))
nChar-='A';
else
nChar=26;
m_treeFiles.InsertItem(dataFind.cFileName,hLetter[nChar]);
}
bMoreFiles=FindNextFile(hFind,&dataFind);
}
FindClose(hFind);}
实际效果:问题1,点击c盘和d盘,出来A-Z的根节点,但是出不来相应的文件;问题2,点击e盘和f盘就出错说内存不能读。大家帮忙看看哪里出错了哈。辛苦大家啦~~
void CHView::OnSelchangeCombo1() //选择combobox的不同选项触发,m_combo为关联的组合框变量
{
// TODO: Add your control notification handler code here
int nIndex=m_combo.GetCurSel();
if(nIndex!=CB_ERR)
{
m_combo.GetLBText(nIndex,m_strMainDir);
PopulateTree();
}
}
void CHView::PopulateTree()、、m_treeFiles为关联的树形控件变量,
{
m_treeFiles.DeleteAllItems();
HTREEITEM hLetter[27];
for(int i='A';i<='Z';i++)
{
hLetter[i-'A']=m_treeFiles.InsertItem((TCHAR*)&i);
}
hLetter[26]=m_treeFiles.InsertItem("other");
HANDLE hFind;
WIN32_FIND_DATA dataFind;
BOOL bMoreFiles=TRUE;
CString strFile;
hFind=FindFirstFile(m_strMainDir+"\\*.*",&dataFind);
while(hFind!=INVALID_HANDLE_VALUE&&bMoreFiles==TRUE)
{
if(dataFind.dwFileAttributes==FILE_ATTRIBUTE_ARCHIVE)
{
int nChar=dataFind.cFileName[0];
if(islower(nChar))
nChar-=32;
if(isalpha(nChar))
nChar-='A';
else
nChar=26;
m_treeFiles.InsertItem(dataFind.cFileName,hLetter[nChar]);
}
bMoreFiles=FindNextFile(hFind,&dataFind);
}
FindClose(hFind);}
相关文章推荐
- SharePoint2010沙盒解决方案基础开发——关于TreeView树形控件读取列表数据(树形导航)的webpart开发及问题
- SharePoint2010沙盒解决方案基础开发——关于TreeView树形控件读取列表数据(树形导航)的webpart开发及问题
- SharePoint2010沙盒解决方案基础开发——关于TreeView树形控件读取列表数据(树形导航)的webpart开发及问题
- SharePoint2010沙盒解决方案基础开发——关于TreeView树形控件读取列表数据(树形导航)的webpart开发及问题
- 关于树形控件的一些问题
- SharePoint2010沙盒解决方案基础开发——关于TreeView树形控件读取列表数据(树形导航)的webpart开发及问题
- 关于Asp.net的FormView控件中,用FindControl方法找不到对应控件问题
- 关于DataGrid Web控件的热门问题
- 关于控件的问题, 欢迎解读!!
- vb中关于mscal.ocx控件的显示问题
- 关于ActiveReport使用ActivexViewer输出时,客户端不会提示下载控件的问题.
- 关于控件注册和使用许可问题的解决办法
- [导入]关于ASP.net里的级联DropdownList控件问题!
- 一个关于多对话框和CListCtrl控件的问题(棘手)。
- 关于用户控件事件丢失问题解决
- 关于非顶级窗体的输入栏控件焦点问题
- ASP.Net关于Validator控件的奇怪问题
- C#写的计数器控件 - 一个关于相对路径使用的问题
- 关于博友mmiluy的弹出式Calendar控件的问题 推荐
- 关于.Net 1.1 Windows Forms 控件的一个小问题