分类: 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
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;