本文整理汇总了C++中CFileDialog::GetFileExt方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileDialog::GetFileExt方法的具体用法?C++ CFileDialog::GetFileExt怎么用?C++ CFileDialog::GetFileExt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileDialog
的用法示例。
在下文中一共展示了CFileDialog::GetFileExt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnFileSave
void CPLViewerDoc::OnFileSave()
{
CFileDialog SaveDlg (false, ".jpg", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"JPEG File (*.jpg)|*.jpg|Windows Bitmap (*.bmp)|*.bmp|TIFF File (*.tif)|*.tif|PNG File (*.png)|*.png|",
AfxGetMainWnd());
if (SaveDlg.DoModal() == IDOK)
{
CString sFName = SaveDlg.GetPathName();
CString sExt = SaveDlg.GetFileExt();
sExt.MakeLower();
try
{
if (sExt == "jpg")
{
PLJPEGEncoder Encoder;
Encoder.MakeFileFromBmp(sFName, m_pDib);
}
else if (sExt == "tif")
{
PLTIFFEncoder Encoder;
Encoder.MakeFileFromBmp(sFName, m_pDib);
}
else if (sExt == "png")
{
PLPNGEncoder Encoder;
Encoder.MakeFileFromBmp(sFName, m_pDib);
}
else if (sExt == "bmp")
{
PLBmpEncoder Encoder;
Encoder.MakeFileFromBmp(sFName, m_pDib);
}
else
{
// Extension must be one of the supported types. If not,
// something is wrong in the user interface code.
ASSERT (false);
}
}
catch(PLTextException e)
{
CString bmpEx;
bmpEx.Format("Error saving the file: %s",
(LPCTSTR) e,
(LPCTSTR) e.GetCode());
AfxMessageBox(bmpEx);
}
}
}
示例2: if
void CDialConfigDec::OnButton1()
{
CFile Fichier; // variable fichier
BYTE compnbpar;
CFileDialog * FileData = new CFileDialog (TRUE,"*.pmc",NomFichPMC,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Polytopes multi-classes (*.pmc)|*.pmc|",this);
if (FileData->DoModal()==IDOK)
{
if(FileData->GetFileExt()!="pmc")
{
MessageBox("Le fichier selectionné n'est pas valide!","Erreur",MB_OK|MB_ICONSTOP);
m_pmc.SetWindowText("*.pmc");
ValidPMC=FALSE;
}
else if (Fichier.Open(FileData->GetPathName(), CFile::modeRead))
{
Fichier.Read(&NBclass,1);
Fichier.Read(&compnbpar,1);
Fichier.Close();
NomFichPMC=FileData->GetPathName();
m_pmc.SetWindowText(FileData->GetFileName());
ValidPMC=TRUE;
if(compnbpar!=NBpar)
{
NBpar=compnbpar;
m_param.SetWindowText("*.param");
ValidPARAM=FALSE;
}
m_classeaffect=0;
m_spin.SetPos(0);
m_spin.SetRange(0,NBclass-1);
if(!m_check) m_edit1.SetWindowText("");
}
else
{
MessageBox("Le fichier "+FileData->GetFileName()+" n'existe pas!","Erreur",MB_OK|MB_ICONSTOP);
ValidPMC=FALSE;
}
}
m_ok.EnableWindow(ValidPARAM&&ValidPMC);
m_checkbox.EnableWindow(ValidPARAM&&ValidPMC);
m_param.EnableWindow(ValidPMC);
UpdateData(FALSE);
delete FileData;
}
示例3: OnFileSaveAs
void CdcmviewerView::OnFileSaveAs()
{
// save dicom as bmp/jpeg/png/gif/tif
if(!m_pdib.get())
return;
static char BASED_CODE szFilters[] = "Jpeg Files (*.jpg)|*.jpg|Bitmap Files (*.bmp)|*.bmp|Png Files (*.png)|*.png|GIF Files (*.gif)|*.gif|TIFF Files (*.tif)|*.tif||";
CFileDialog ofdlg (FALSE, ".bmp", NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
OFN_PATHMUSTEXIST |OFN_EXPLORER, szFilters, AfxGetMainWnd());
if(IDOK==ofdlg.DoModal())
{
CString pathname = ofdlg.GetPathName();
CString fileext = ofdlg.GetFileExt();
DWORD index = ofdlg.m_ofn.nFilterIndex;
if(index==2)
{
CFile fbmp;
if(end_with((LPCTSTR)pathname,_T(".bmp"))==false)
pathname += _T(".bmp");
if(fbmp.Open(pathname,CFile::modeCreate|CFile::modeWrite))
{
m_pdib->Write(&fbmp);
}
fbmp.Close();
}
else if( 3 == index)
{
save_dcm_as_image(pathname,".png",m_pdib.get());
}
else if( 4 == index)
{
save_dcm_as_image(pathname,".gif",m_pdib.get());
}
else if( 5 == index)
{
save_dcm_as_image(pathname,".tif",m_pdib.get());
}
else
{
save_dcm_as_image(pathname,".jpg",m_pdib.get());
}
}
}
示例4: OnFileOpen
void CChildView::OnFileOpen()
{
CString szFilter = _T ("DICOM Files (*.dcm)|*.dcm|bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*|");
CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
OFN_ALLOWMULTISELECT, szFilter, this);
if(dlg.DoModal () == IDCANCEL)
return;
CString ext = dlg.GetFileExt();
ext.MakeUpper(); //capital character
if(ext == L"BMP")
OpenBITMAPFile(dlg.GetPathName());
else if(ext == L"DCM")
OpenDICOMFile(dlg.GetPathName());
Invalidate(FALSE);
}
示例5: OnBnClickedBrowseModelName
void CDlgDefineModel::OnBnClickedBrowseModelName()
{
CFileDialog fileDlg (FALSE, _T(""), _T("*.*"), OFN_HIDEREADONLY, _T(""), this);
OPENFILENAME& ofn = fileDlg.GetOFN();
CString strDlg("Specify model root name");
ofn.lpstrTitle = strDlg;
if( fileDlg.DoModal() == IDOK ) {
CString strExt = fileDlg.GetFileExt();
CString strName = fileDlg.GetFileName();
m_strFilePathModel = fileDlg.GetPathName();
if( !strExt.IsEmpty()) {
m_strFilePathModel.Replace( _T(".")+strExt, _T(""));
}
if( !strName.IsEmpty()) {
m_strFilePathTmp.Replace( _T("\\")+strName, _T(""));
}
m_pInvFcs->SetFileRoot( m_strFilePathModel );
m_pInvFcs->SetPathTmp( m_strFilePathModel );
SetDlgItemText(IDC_MODEL_NAME, m_strFilePathModel);
SetDlgItemText(IDC_TEMP_DIR, m_strFilePathModel);
}
}
示例6: ExportDownloads
//.........这里部分代码省略.........
vpDlds.push_back (dld);
}
_DldsMgr.UnlockList (true);
}
break;
case 1:
{
CDownloads_Tasks* list = &_pwndDownloads->m_wndDownloads.m_tasks;
int cItems = list->GetItemCount ();
for (int i = 0; i < cItems; i++)
{
vmsDownloadSmartPtr dld;
try
{
dld = (fsDownload*) list->GetItemData (i);
if (bNoDone && dld->pMgr->IsDone ())
dld = NULL;
}
catch (const std::exception& ex)
{
ASSERT (FALSE);
vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads " + tstring(ex.what()));
dld = NULL;
}
catch (...)
{
ASSERT (FALSE);
vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads unknown exception");
dld = NULL;
}
if (dld)
vpDlds.push_back (dld);
}
}
break;
case 2:
{
CDownloads_Tasks* list = &_pwndDownloads->m_wndDownloads.m_tasks;
POSITION pos = list->GetFirstSelectedItemPosition ();
while (pos)
{
int iItem = list->GetNextSelectedItem (pos);
vmsDownloadSmartPtr dld;
try
{
dld = (fsDownload*) list->GetItemData (iItem);
if (bNoDone && dld->pMgr->IsDone ())
dld = NULL;
}
catch (const std::exception& ex)
{
ASSERT (FALSE);
vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads " + tstring(ex.what()));
dld = NULL;
}
catch (...)
{
ASSERT (FALSE);
vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads unknown exception");
dld = NULL;
}
if (dld)
vpDlds.push_back (dld);
}
}
break;
}
if (vpDlds.empty ())
{
AfxGetApp ()->m_pMainWnd->MessageBox (LS (L_NODLDSTOEXPORT), NULL, MB_ICONEXCLAMATION);
}
else
{
CString strFilter;
strFilter.Format ("%s (*.txt)|*.txt|%s (*.xml)|*.xml||", LS (L_URLLISTFILES), LS (L_DLINFOLISTFILES));
UINT flags = OFN_NOCHANGEDIR;
if (bAppend == FALSE)
flags |= OFN_OVERWRITEPROMPT;
CFileDialog dlg (FALSE, "txt", NULL, flags, strFilter, NULL);
if (_DlgMgr.DoModal (&dlg) == IDCANCEL)
return;
if (dlg.GetFileExt ().CollateNoCase ("txt") == 0)
ExportDownloads_ToURLListFile (dlg.GetPathName (), &vpDlds, bAppend);
else
ExportDownloads_ToDLInfoListFile (dlg.GetPathName (), &vpDlds, bAppend);
}
}