多选择文件打开对话框

 

多选择文件打开对话框

 

关键点

可以打开多个文件

 

实现过程

 

CString filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*||";
CFileDialog OpenFileDialog(TRUENULL"*.txt"OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECTfilter);
//     OpenFileDialog.m_ofn.lpstrInitialDir = "D:\\";
//  OpenFileDialog.m_ofn.lpstrTitle="Open File";
CString Msg;
if(OpenFileDialog.DoModal() == IDOK)   
{
    POSITION pos;
    pos=OpenFileDialog.GetStartPosition();//开始遍历用户选择文件列表
    while (pos!=NULL)
    {
        CString filename=OpenFileDialog.GetNextPathName(pos);
        Msg+=filename+"\r\n";
   }
    MessageBox(Msg);
}    

 

 

 

   


 

备注

 

 

相关链接

                           

 

 




posted @ 2014-05-17 21:09  XE2011  阅读(187)  评论(0编辑  收藏  举报