本文整理汇总了C++中CFileDialog类的典型用法代码示例。如果您正苦于以下问题:C++ CFileDialog类的具体用法?C++ CFileDialog怎么用?C++ CFileDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CFileDialog
void CAfficheMesPol::OnVisualisationChoixdunfichierdepolytopes()
{
BYTE NbPar=PolyMc.NPAR;
CPolyMc test;
CFileDialog * FileData = new CFileDialog (TRUE,"*.pmc",NomFichierPol,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Polytopes multi-classes (*.pmc)|*.pmc||",this);
if(FileData->DoModal()==IDOK)
{
test.LirePol(FileData->GetPathName());
test.Fin();
if(PolyMc.NPAR!=test.NPAR||PolyMc.NbClass!=test.NbClass)
{
MessageBox("Fichier polytope incompatible!","Erreur!",MB_OK|MB_ICONSTOP);
ValidPol=FALSE;
Visu=FALSE;
}
else
{
ValidPol=TRUE;
NomFichierPol=FileData->GetPathName();
PolyMc.Fin();
ValidPol=PolyMc.LirePol(NomFichierPol);
}
}
Invalidate(TRUE);
delete FileData;
}
示例2: OnImportImage
void CImageMgr::OnImportImage()
{
if( fontGen->GetStatus() != 0 ) return;
CFileDialog dlg;
dlg.AddFilter("All files (*.*)", "*.*");
dlg.AddFilter("Supported image files (*.bmp;*.jpg;*.tga;*.dds;*.png)", "*.bmp;*.jpg;*.tga;*.dds;*.png", true);
if( dlg.AskForOpenFileName(this) )
{
CIconImageDlg iconDlg;
iconDlg.fileName = dlg.GetFileName();
iconDlg.id = 0;
iconDlg.xoffset = 0;
iconDlg.yoffset = 0;
iconDlg.advance = 0;
if( iconDlg.DoModal(this) == IDOK )
{
// Create the icon image
int r = fontGen->AddIconImage(iconDlg.fileName.c_str(),
iconDlg.id,
iconDlg.xoffset,
iconDlg.yoffset,
iconDlg.advance);
if( r < 0 )
{
MessageBox(hWnd, "Failed to load image file", "File error", MB_OK);
return;
}
RefreshList();
}
}
}
示例3: Files
void CEditorView::OnPopupLoad()
{
// TODO: Add your command handler code here
BOOL endmarker;
CString FileName;
CString WindowText;
CString WindowLine;
static char BASED_CODE szFilter[] = "Text Files (*.txt)|*.txt|Data Files (*.dat)|*.dat|All Files (*.*)|*.*||";
CFileDialog* pLoadFile = new CFileDialog(TRUE,NULL,NULL,0,&szFilter[0],NULL);
if (IDOK==pLoadFile->DoModal())
{
WindowText = "";
FileName = pLoadFile->GetPathName();
delete pLoadFile;
CStdioFile* pFile = new CStdioFile(FileName,CFile::modeRead);
do
{
endmarker = pFile->ReadString(WindowLine);
WindowText = WindowText+WindowLine+"\r\n";
}
while (endmarker);
GetEditCtrl().SetSel(-1,0,FALSE);
GetEditCtrl().ReplaceSel(WindowText);
pFile->Close();
delete pFile;
}
}
示例4: AfxThrowResourceException
void CCompactDataBase::OnFileName() // OK
{
// TODO: Add your control notification handler code here
CString strExt, strFilter, strCaption;
if (!strExt.LoadString (IDS_DATABASE_EXTENSION) ||
!strCaption.LoadString (IDS_COMPACT_CAPTION) ||
!strFilter.LoadString (IDS_MDB_FILTER))
AfxThrowResourceException ();
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; // voreingest.
CFileDialog Dlg (FALSE, strExt, NULL, dwFlags, strFilter, this);
Dlg.m_ofn.lpstrInitialDir = m_strDir;
Dlg.m_ofn.lpstrTitle = strCaption;
if (IDOK == Dlg.DoModal ())
{
CString strNewDatabase;
strNewDatabase = Dlg.GetPathName ();
if (0 != m_strOldDatabase.CompareNoCase (strNewDatabase))
{
strNewDatabase.MakeUpper ();
m_edFileName.SetWindowText (strNewDatabase);
}
else
// Namen müssen verschieden sein --> Meldung an Nutzer
{
CGakApp *pApp = (CGakApp *) AfxGetApp ();
ASSERT (pApp != NULL);
ASSERT_VALID (pApp);
pApp -> OutputMessage (IDS_DIFF_DATABASE);
}
}
}
示例5: UpdateData
/////////////////////////////////////////////////////////////////////////////
// CCmdGF message handlers
void CCmdGF::OnGfExt()
{
UpdateData(TRUE);
CMainFrame* main;
main=(CMainFrame*)AfxGetMainWnd();
CFRTK* face = &((CSoftComputingWndDoc*)main->GetActiveDocument())->m_frtk;
IPLIMAGE image = ((CSoftComputingWndDoc*)main->GetActiveDocument())->m_image;
CFileDialog *pDlg = new CFileDialog( TRUE, NULL, NULL, OFN_READONLY,
"얼굴모델 *.dat|*.dat|모든파일 *.*|*.*|", NULL );
if (pDlg->DoModal())
{
CString filename = pDlg->GetFileName();
if (filename != "")
{
CFRTKface facecomp;
facecomp.load(filename);
face->FRTKgeofeat(image, NULL, m_source, m_result, facecomp);
}
}
}
示例6: D
void CRossScheme::OnBnClickedSaveToFiles()
{
CFileDialog D (FALSE, 0,"D_", OFN_NOVALIDATE);
if (!D.DoModal()) return;
string Path = GetPathByFile((const char*)D.GetPathName());
size_t i=0;
for (; i<GetRoss()->m_Domens.size(); i++)
{
const CDomen& D = GetRoss()->m_Domens[i];
if (D.IsFree) continue;
string FileName = Path + (const char*)D.DomStr + string(".txt");
FILE* fp = fopen (FileName.c_str(), "w");
for (size_t k = 0; k < D.m_ItemsLength; k++)
fprintf (fp, "%s\n", (const char*)D.m_Items[k]);
fclose(fp);
};
if (::MessageBox(m_hWnd, "Export of metaconstants was finished! Delete all meta constants?" , "Question",MB_YESNO) == IDNO) return;
for (int k = GetRoss()->m_Domens.size()-1; k>=0; k--)
{
const CDomen& D = GetRoss()->m_Domens[GetRoss()->GetDomItemDomNo(k)];
if (D.IsFree) continue;
GetRoss()->DelDomItem(k);
};
m_pRossDoc->SetModifiedFlag(TRUE);
}
示例7: dlg
void CDlg_ImportNetwork::OnBnClickedExportData()
{
CString m_CSV_FileName;
CFileDialog dlg (FALSE, "*.csv", "*.csv",OFN_HIDEREADONLY | OFN_NOREADONLYRETURN | OFN_LONGNAMES,
"(*.csv)|*.csv||", NULL);
if(dlg.DoModal() == IDOK)
{
FILE* st;
fopen_s(&st,dlg.GetPathName(),"w");
if(st!=NULL)
{
for(int i=0; i< m_MessageList.GetCount (); i++) // if one of "all" options is selected, we need to narrow down to OD pair
{
char m_Text[200];
m_MessageList.GetText (i, m_Text);
fprintf(st,"%s\n",m_Text);
}
fclose(st);
}else
{ CString str;
str.Format("The file %s could not be opened.\nPlease check if it is opened by Excel.", dlg.GetPathName());
AfxMessageBox(str);
}
m_pDoc->OpenCSVFileInExcel (dlg.GetPathName());
}
}
示例8: CFileDialog
void CChildView::OnFileSave()
{
CFileDialog* fd = new CFileDialog(false, _T("jfd"), _T("*.jfd"));
wstring fileName;
fd->m_ofn.lpstrTitle = TEXT("Save file");
fd->m_ofn.lpstrFilter = TEXT("JFDraw Files (*.jfd)");
if (fd->DoModal() == IDOK)
{
fileName = fd->GetPathName();
ofstream file;
file.open(fileName);
if (m_Shapes.empty() == false)
{
for (auto i : m_Shapes)
{
file << i->ToString();
}
}
file.close();
delete fd;
}
}
示例9: CFileDialog
void CSub::OnButtonChooseProgram()
{
CFileDialog *fd = new CFileDialog(TRUE, "zap", NULL, OFN_HIDEREADONLY | OFN_NOCHANGEDIR , "Zap! Files (*.zap)|*.zap||", this);
CString DefaultPath = ((CFlowZap*)m_fc)->GetDefaultZapDirectory();
fd->m_ofn.lpstrInitialDir = DefaultPath;
int response = fd->DoModal();
if (response == IDOK)
{
m_NameOfFile = fd->GetPathName();
CString filename = GetFileNameFromPath(m_NameOfFile);
m_ChooseProgram.SetWindowText("[" + filename + "]");
CFlowZap *fc = (CFlowZap*)m_fc;
fc->ChangeMadeInFile();
m_tooltip.AddTool(GetDlgItem(IDC_CHOOSEPROGRAM), m_NameOfFile);
}
delete fd;
fd = NULL;
}
示例10: GetOwnerList
//****************************************************************************************
void CFileItem::OnClickButton (CPoint /*point*/)
{
CBCGPGridCtrl* pGridCtrl = GetOwnerList();
m_bButtonIsDown = TRUE;
Redraw ();
CString strPath = (LPCTSTR)(_bstr_t)m_varValue;
CFileDialog dlg (TRUE, strPath);
if (dlg.DoModal () == IDOK)
{
strPath = dlg.GetPathName ();
m_varValue = (LPCTSTR) strPath;
}
m_bButtonIsDown = FALSE;
Redraw ();
if (m_pWndInPlace != NULL)
{
m_pWndInPlace->SetWindowText (strPath);
m_pWndInPlace->SetFocus ();
}
else
{
pGridCtrl->SetFocus ();
}
}
示例11: dlgFile
BOOL CGeorgesEditDocForm::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// User mode ?
if (theApp.Superuser)
{
// Choose a DFN for this form
string defFilename = theApp.RootSearchPath;
defFilename += "*.dfn";
CFileDialog dlgFile (TRUE, "*.dfn", defFilename.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, DfnFilter, theApp.m_pMainWnd);
if (dlgFile.DoModal () == IDOK)
{
if (initDocument (dlgFile.GetFileName (), true))
return TRUE;
}
}
else
{
// Get the Dfn name
CMyMultiDocTemplate *docTemplate = safe_cast<CMyMultiDocTemplate*> (GetDocTemplate ());
string dfnName;
docTemplate->getDfnName (dfnName);
if (initDocument (dfnName.c_str (), true))
return TRUE;
}
return FALSE;
}
示例12: OnBrowsemotion
void CMotionsDlg::OnBrowsemotion()
{
CFileDialog *FileDlg = MyFileDialog_Create
(
TRUE, IDS_MOTIONFILEPROMPT, IDS_MOTFILEEXT, IDS_MOTFILEFILTER,
m_MotionFilename, OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST, this
);
if (FileDlg != NULL)
{
if (FileDlg->DoModal () == IDOK)
{
char NewMotionName[MAX_PATH];
SetModifiedFlag (true);
strcpy (NewMotionName, m_MotionFilename);
if (MakeHelp_GetRelativePath (m_Project, FileDlg->GetPathName (), NewMotionName))
{
m_MotionFilename = NewMotionName;
SetMotionTypeFromFilename ();
m_FilenameChanged = false;
}
UpdateData (FALSE);
}
delete FileDlg;
}
else
{
AfxMessageBox (IDS_OUTOFMEMORY);
}
}
示例13: OnSelectCharsFromFile
void CCharWin::OnSelectCharsFromFile()
{
if( isGenerating ) return;
CFileDialog dlg;
dlg.AddFilter("All files (*.*)", "*.*", true);
if( dlg.AskForOpenFileName(this) )
{
fontGen->SelectCharsFromFile(dlg.GetFileName().c_str());
int countMissing = fontGen->GetNumFailedChars();
if( countMissing )
{
stringstream s;
s << countMissing << " characters from the file are not available in the font";
TCHAR buf[1024];
ConvertAnsiToTChar(s.str(), buf, 1024);
MessageBox(hWnd, buf, __TEXT("Warning"), MB_OK);
}
UpdateSubsetsSelection();
Invalidate(FALSE);
}
}
示例14: CFileDialog
void CMEADialog::OnBnClickedPartition()
{
//Get the name of the partition function save file and post it to the view
//Open the standard dialog to pick a sequence
char *ctname;
short int i;
CFileDialog *filedialog;
filedialog = new CFileDialog(TRUE,NULL,"",OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,
"Partition Function Save Files (*.pfs)|*.pfs||");
filedialog->m_ofn.lpstrInitialDir=GetFoldDocument()->startpath;
if (filedialog->DoModal()==IDOK) {
//strcpy(m_sequencename.GetBuffer(10),(filedialog->GetPathName()).GetBuffer(0));
m_SEQUENCE=(filedialog->GetPathName()).GetBuffer(30);
i = m_SEQUENCE.GetLength();
ctname = new char[i+4];//allocate enough space so that
//three characters can be added
//to the name if necessary
strcpy(ctname,m_SEQUENCE.GetBuffer(10));
//count the characters to the .
while(i>=0){
if (ctname[i]=='.') break;
i--;
}
if (i==0) i = m_SEQUENCE.GetLength();
strcpy(ctname+i+1,"ct\0");
m_CT=ctname;
delete[] ctname;//fix this?
UpdateData(FALSE);
//now store the path in Startpath so that the program can start here next time:
//_getcwd(GetFoldDocument()->startpath,_MAX_PATH);
//now store the path in Startpath so that the program can start here next time:
//_getcwd(GetFoldDocument()->startpath,_MAX_PATH);
CString path;
path = filedialog->GetPathName();
i = path.GetLength();
while(i>=0){
if (path[i]=='\\') break;
i--;
}
if (i>_MAX_PATH) i = _MAX_PATH;
strncpy(GetFoldDocument()->startpath,path.GetBuffer(1),i);
*(GetFoldDocument()->startpath + i) ='\0';
}
delete filedialog;
}
示例15: CFileDialog
void CProjectView::OnFileadd()
{
// Start in the project directory
((CProjectDoc*)GetDocument())->SetProject();
_TCHAR* FileBuffer = new _TCHAR[4096];
CFileDialog *pfileDlg = NULL;
if (g_osrel >= 4)
{
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
}
else
{
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
}
pfileDlg->m_ofn.lpstrFile = FileBuffer;
FileBuffer[0] = EOS; // Note, must do this or W95 flags as error
pfileDlg->m_ofn.nMaxFile = 4096;
if (pfileDlg->DoModal() != IDOK)
{
//_TCHAR errbuf[512];
//wsprintf(errbuf, _T("FileDialog error: %d"), CommDlgExtendedError());
//AfxMessageBox(errbuf);
delete pfileDlg;
return;
}
CListBox* pLB = (CListBox*)GetDlgItem(IDP_FILELIST);
// Loop through all the files to be added. If they are in the project
// directory or below, just put in the relative path.
POSITION pos = pfileDlg->GetStartPosition();
CString dir(m_directory), path, upath;
dir.MakeUpper();
int i, idx;
while (pos != NULL)
{
path = pfileDlg->GetNextPathName(pos);
upath = path;
upath.MakeUpper();
if (dir.Right(1) != _T("\\"))
dir = dir + _T("\\");
i = upath.Find(dir);
if (i >= 0)
path = path.Mid(i+dir.GetLength());
idx = pLB->AddString(path);
update_scroll(pLB, path);
}
delete FileBuffer;
delete pfileDlg;
((CProjectDoc*)GetDocument())->SetProject();
}