VC++ CFileDialog 读取多个文件

  //定制文件对话框
 CFileDialog dlg(TRUE, 
     "DEM Files (*DEM)", 
     NULL,
     OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |OFN_ALLOWMULTISELECT|OFN_ENABLESIZING,
     _T("Layer Files (*.DEM;*.TIFF;*.BMP;*.JPG)|*.DEM;*.TIFF;*.BMP;*.JPG;)||"),
     NULL);
 dlg.m_ofn.lpstrTitle="请加载相关图层";
 //最多可以打开100个文件
 dlg.m_ofn.nMaxFile = 100 * MAX_PATH; 
 dlg.m_ofn.lpstrFile = new TCHAR[dlg.m_ofn.nMaxFile];  
 ZeroMemory(dlg.m_ofn.lpstrFile, sizeof(TCHAR) * dlg.m_ofn.nMaxFile); 
 
 //显示文件对话框,获得文件名集合
 int retval = dlg.DoModal();
 if(retval==IDCANCEL)
  return false;
 POSITION pos_file;
 pos_file = dlg.GetStartPosition();
 CArray<CString, CString> ary_filename;
    while(pos_file != NULL)
  ary_filename.Add(dlg.GetNextPathName(pos_file));

 //根据扩展名读取相关文件
 for(int i=0; i<ary_filename.GetSize(); i++)
 {
  CString str_ext;
  str_ext = ary_filename.GetAt(i).Right(3);
  if((str_ext == "DEM")||(str_ext == "dem"))
  {
  }
  else if((str_ext == "TIFF")||(str_ext == "tiff"))
  {
  }
  else if((str_ext == "BMP")||(str_ext == "bmp"))
  {
  }
  else if((str_ext == "JPG")||(str_ext == "jpg"))
  {
  }
  else if((str_ext == "SHP")||(str_ext == "shp"))
  {
  }
 } 
 return true;

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值