您的位置:首页 > 其它

关于树形控件和组合框的问题~

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);}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐