I am working on a win32 MFC project. I have a dialog with two CMFCEditBrowseCtrl controls. After the user indicates the files of these controls, how do I get the file paths from these controls?
Update: here is my code
SpecifyInputDialog dlg; // this is my dialog inherited from CDialogEx
dlg.DoModal();
CString strText;
dlg.inFileCtrl.GetWindowTextA(strText.GetBuffer(), 500); // inFileCtrl is CMFCEditBrowseCtrl object
Results in the "Debug Assertion Failed" error on the last line ...
Update 2:
CString strText;
dlg.inFileCtrl.GetWindowText(strText);
The same error is "Debugging Error". I will try to get the text until the dialog is tried.
Update 3 (solution):
I managed to get the path text by doing a callback
BEGIN_MESSAGE_MAP(SpecifyInputDialog, CDialogEx)
ON_EN_CHANGE(IDC_MFCEDITBROWSE1, &SpecifyInputDialog::OnEnChangeMfceditbrowse1)
END_MESSAGE_MAP()
And in the handler method:
void SpecifyInputDialog::OnEnChangeMfceditbrowse1()
{
this->inFileCtrl.GetWindowText(this->inFileString);
}
So, your idea that the text was not yet closed during the dialogue was right. Please update your answer so that I could mark it as a solution.