المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl?



C++ Programming
07-11-2017, 07:31 AM
Hello! I'm trying to browse a text file using CMFCEditBrowseCtrl (it is used in CFirstDialog Class) and use this file in another Dialog Class (named CSecondDialog Class). My problem is on how to save the filename retrieved from the CMFCEditBrowseCtrl when the CFirstDialog::OnEnChangeMfceditbrowse1() goes out of scope and then pass the filename to the CSecondDialog. Here is the code:

void CFirstDialog::OnEnChangeMfceditbrowse1(){ CString str; m_browser.GetWindowText(str); //CMFCEditBrowseCtrl m_browser (variable)}

void CSecondDialog::OnBnClickedOk(){CStdioFile fileSource("here I need to put the filename retrieved from the previous dialog class", CFile::modeRead);CStdioFile fileDest;CString strLine;CString strFile;int num = 1; while (fileSource.ReadString(strLine)){ strFile.Format(L"over%d.txt", num++); fileDest.Open(strFile, CFile::modeWrite); fileDest.WriteString(strLine); fileDest.Close();} fileSource.Close(); }