zoukankan      html  css  js  c++  java
  • CFileDialog 多文件选择

    CString pathName = _T("");
    CString fileName = _T("");
    CString strMulfilepath = _T("");

    //创建一个可以选择多个文件的CFileDialog
    CFileDialog fileDlg(true,NULL,_T("*.*"),OFN_ALLOWMULTISELECT | OFN_ENABLESIZING | OFN_HIDEREADONLY,_T("All Files (*.*)|*.*||"));

    m_filepath.clear();
    //最多可以打开500个文件
    fileDlg.m_ofn.nMaxFile = 500 * MAX_PATH;

    TCHAR* ch = new TCHAR[fileDlg.m_ofn.nMaxFile];
    fileDlg.m_ofn.lpstrFile = ch;

    //对内存块清零
    ZeroMemory(fileDlg.m_ofn.lpstrFile,sizeof(TCHAR) * fileDlg.m_ofn.nMaxFile);

    //显示文件对话框,获得文件名集合
    if(fileDlg.DoModal() == IDOK){

    //获取第一个文件的位置
    POSITION pos_file;
    pos_file = fileDlg.GetStartPosition();

    //循环读出每个路径并存放在数组中
    while(pos_file != NULL){

    //将文件路径存放在数组中
    pathName = fileDlg.GetNextPathName(pos_file);

    int len =WideCharToMultiByte(CP_ACP,0,pathName,-1,NULL,0,NULL,NULL);
    char *cfname =new char[len +1];
    WideCharToMultiByte(CP_ACP,0,pathName,-1,cfname,len,NULL,NULL );

    //ary_filename.Add(pathName);
    m_filepath.push_back(cfname);

    strMulfilepath += pathName;
    }
    }

    SetDlgItemText(IDC_EDIT1, strMulfilepath);
    delete[] ch;

  • 相关阅读:
    ansible——playbook conditions条件判断
    ansible——playbook lookups从插件加载变量
    ansible——playbook循环
    lombok注解
    集合与集合取笛卡尔积
    List排列组合
    synchronized初识
    java IO与NIO
    文件I/O和标准I/O
    双数据源配置
  • 原文地址:https://www.cnblogs.com/whwywzhj/p/8431417.html
Copyright © 2011-2022 走看看