Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1027941
  • 博文数量: 288
  • 博客积分: 10306
  • 博客等级: 上将
  • 技术积分: 3182
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-12 17:00
文章分类

全部博文(288)

文章存档

2011年(19)

2010年(38)

2009年(135)

2008年(96)

我的朋友

分类: C/C++

2009-09-14 14:32:56

一.同时打开多个文件:

  //定制文件对话框
 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 ary_filename;
    while(pos_file != NULL)
  ary_filename.Add(dlg.GetNextPathName(pos_file));

 //根据扩展名读取相关文件
 for(int i=0; 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;

阅读(1161) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~