I'm working on MFC win32 project. I have dialog with 2 CMFCEditBrowseCtrl controls. After user specifies files on these controls, how to get 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 "Debug Assertion Failed" error on last line...
Update 2:
CString strText;
dlg.inFileCtrl.GetWindowText(strText);
The same "Debug Assertion Failed" error. I will try to get text while dialog not dissmissed.
Update 3 (solved):
I managed to get path text by implementing callback
BEGIN_MESSAGE_MAP(SpecifyInputDialog, CDialogEx)
ON_EN_CHANGE(IDC_MFCEDITBROWSE1, &SpecifyInputDialog::OnEnChangeMfceditbrowse1)
END_MESSAGE_MAP()
And in handler method:
void SpecifyInputDialog::OnEnChangeMfceditbrowse1()
{
this->inFileCtrl.GetWindowText(this->inFileString);
}
So your thought about getting text while dialog are not closed yet was right. Please update your answer thus I could mark it as solution.