VC打开多个文件对话框

try
{
CString str( "" ,10000); //这是做为存放打开文件名和路径的字符串空间10000这个值的设置就觉得有些不妥当
CFileDialog openfile( true ,NULL,NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT, "All Files(*.*)|*.*|" ,AfxGetMainWnd());
openfile.m_ofn.lpstrFile=str.GetBuffer(10000);
openfile.m_ofn.nMaxFile=10000;
openfile.m_ofn.lStructSize= sizeof (openfile.m_ofn);
CString pathname( "" ,MAX_PATH);
CFileStatus status;
openfile.DoModal();
 
POSITION mPos=openfile.GetStartPosition();
while (mPos!=NULL){
pathname=openfile.GetNextPathName(mPos);
CFile::GetStatus(pathname,status);
this ->m_listresult.InsertItem(count++,pathname); //把包括路径在内的文件名写到一个list控件里
}
}
catch  (CException* e)
{
AfxMessageBox(_T( "打开文件出错了!" ));
e->Delete();
}

此文章来自于【http://www.cnblogs.com/joeblackzqq/archive/2010/12/19/1910900.html】

你可能感兴趣的:(基本控件,文件对话框)