Hi You can use the Return value of CFileDialog::DoModa(), Function. If it is IDOK the user selected a file and closed the dialog by clicking on open button and if it is IDCANCEL the dialog was closed using cancel button or X button.
Example:
CFileDialog FileDilog;
if(FileDialog.DoModal() == IDOK)
{
CString strFilePath = FileDialog.GetPathName();
}
In case if you want to know allow multiple file selection Use The code,
if (FileDialog.DoModal() == IDOK)
{
POSITION pos = FileDialog.GetStartPosition();
while (pos != NULL)
{
CString strFilePath = FileDialog.GetNextPathName(pos);
}
}
Check MSDN for More info.
http://msdn.microsoft.com/en-us/library/8dwz4azc%28v=vs.80%29.aspx[
^]