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();
}
沒有留言:
張貼留言
(什麼是留言欄訊息?)