CFileDialog
¶CFileDialog
原文連結: https://darkblack01.blogspot.com/2012/05/cfiledialog.html
移植時的最後更新日期: 2012-08-14T09:30:04.261+08:00
CFileDialog fileDlg (
TRUE, //bOpenFileDialog 設置為 TRUE:開啟舊檔;
// FALSE另存新檔
“txt”, //lpszDefExt 檔案類型的內容
“.txt", //lpszFileName 檔案名稱
OFN_ALLOWMULTISELECT, //dwFlags
szFilters, //szFilters 瀏覽過濾器
this //pParentWnd 父視窗指標
//dwSize 預設0:依作業系統預設類型
);
Sample Code:
void CColorEyeIDoc::OnFileOpen()
{
CFileDialog aFileDialog (TRUE, NULL, NULL, OFN_SHAREAWARE | OFN_OVERWRITEPROMPT, m_strFilter);
int nID = aFileDialog.DoModal();
if (nID == IDOK)
{
f_Omd->SetMsrData(vChain1);
if(f_Omd->Open(aFileDialog.GetPathName()))
{
SetPathName(aFileDialog.GetPathName());
SetTitle(aFileDialog.GetFileName());
}
}
UpdateAllViews(NULL);
}
void CColorEyeIDoc::OnFileSaveAs()
{
CFileDialog fSaveDlg (FALSE, “omd”, ".omd”, OFN_SHAREAWARE, m_strFilter); //存檔會自己加副檔名
int nID = fSaveDlg.DoModal();
if (nID == IDOK)
{
f_Omd->SetMsrData(vChain1);
if (f_Omd->Save(fSaveDlg.GetPathName()))
{
SetTitle(fSaveDlg.GetFileName());
SetPathName(fSaveDlg.GetPathName());
}
}
DebugByTxt();
}