CFileDialog 使用 OFN_ALLOWMULTISELECT 标志选择多个文件

来源:互联网 发布:q房网经纪人端口下载 编辑:程序博客网 时间:2024/05/20 01:38
   CFileDialog   dlg( TRUE, NULL, NULL, OFN_ALLOWMULTISELECT, NULL, NULL );   DWORD MAXFILE = 2562; //2562 is the max   TCHAR* pc = new TCHAR[MAXFILE * (MAX_PATH+1) + 1];   pc[0] = pc[1] = 0;   dlg.m_ofn.nMaxFile = MAXFILE;   dlg.m_ofn.lpstrFile = pc;      int iReturn = dlg.DoModal();   if(iReturn ==  IDOK)   {     int nCount = 0;     POSITION pos = dlg.GetStartPosition();     while (pos != NULL)     {       CString szPathName = dlg.GetNextPathName(pos);       TRACE( _T("%s/n"), szPathName);       nCount++;     }     CString str;     str.Format("Successfully opened %d files/n", nCount);     AfxMessageBox(str);   }   else if(iReturn == IDCANCEL)     AfxMessageBox("Cancel");   delete []pc;

http://blog.csdn.net/zgl7903/article/details/5854648


原创粉丝点击