The
CFileDialog
does not open your file. It is used to select files. The button is labeled 'Open' when passing
TRUE
as first parameter (File Open dialog).
When calling
DoModal()
of the file dialog, check the return value. If it is
IDOK
, get the file name by the
GetPathName()
member function and pass it to the dialog with the edit control:
CFileDialog FileDlg(TRUE, ...);
if (IDOK == FileDlg.DoModal())
{
CShowFileDlg ShowDlg; ShowDlg.m_strFileName = FileDlg.GetPathName();
ShowDialog().DoModal();
}
The CShowFileDialog should be created using the dialog resource editor adding a multi line edit control:
class CShowFileDialog : public CDialog
{
...
public:
CEdit m_edit; CString m_strFileName;
...
};
...
DDX_Control(pDX, IDC_EDIT1, m_edit);
...
BOOL CShowFileDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString str;
m_edit.SetWindowText(str.GetString());
return TRUE;
}