kobib
asked on
I want to use defualt ext. filter while using CFileDialog
Hello friends.
I creat a CFileDialog object for browse a file.
I try to use a filter in order to focus on some file type.
Has any body have an idea?
my code look like:
CFileDialog m_ldFile(TRUE);
m_ldFile.m_ofn.lpstrFilter = "*.hex"; m_ldFile.m_ofn.lpstrCustom Filter ;
if (m_ldFile.DoModal() == IDOK)
{
m_sResults = m_ldFile.GetFileName();
UpdateData(FALSE);
}
But it doesn't work. It shows all the files on the director and not just the "hex" files.
Thanks for your help,
Kobi.
I creat a CFileDialog object for browse a file.
I try to use a filter in order to focus on some file type.
Has any body have an idea?
my code look like:
CFileDialog m_ldFile(TRUE);
m_ldFile.m_ofn.lpstrFilter
if (m_ldFile.DoModal() == IDOK)
{
m_sResults = m_ldFile.GetFileName();
UpdateData(FALSE);
}
But it doesn't work. It shows all the files on the director and not just the "hex" files.
Thanks for your help,
Kobi.
Just to correct GloriousRain !
To complete list of filters in szFilters You need to terminate string with two | characters:
TCHAR szFilters[] = _T("Patch Files (*.hex)|*.hex||");
To complete list of filters in szFilters You need to terminate string with two | characters:
TCHAR szFilters[] = _T("Patch Files (*.hex)|*.hex||");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was really what I looked for!
I really don't know what is wrong with GloriousRain answer ?
forget, MadYugoslav. Sedqwick's sample is clearly than me.
OK.
ASKER
Thank you guys.
CPatcherView::GetFileName(
{
TCHAR szFilters[] = _T("Patch Files (*.hex)|*.hex|");
CFileDialog dlg( TRUE, _T("hex"), NULL, OFN_FILEMUSTEXIST |
OFN_HIDEREADONLY, szFilters, this);
CString strTitle(_T(""));
dlg.m_ofn.lpstrTitle = "Select File Name";
if(dlg.DoModal()==IDOK)
{
CString strConfigFileName(_T(""));
strConfigFileName=dlg.GetP
UpdateData(FALSE);
strConfigFileName.MakeUppe
return strConfigFileName;
}
else
return _T("");
}