l_madhavi
asked on
How to disable FileName edit box in CFileDialog?
Hi
I am working in VC++. I'm using CFileDialog class for opening files. Here I am allowing the user to open only text and pdf files by providing a filter in the constructor as shown below.
char szFilter[64];
memset(szFilter, 0, sizeof(szFilter));
strcpy(szFilter, "JobDoc File(*.pdf;*.txt)");
strcpy(&szFilter[strlen(sz Filter)+1] , "*.pdf;*.txt");
CFileDialog fileDlg(TRUE, _T("*.pdf"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR, szFilter);
fileDlg.m_ofn.lpstrFilter = szFilter;
fileDlg.m_ofn.lpstrTitle = "Browse Job Options File";
fileDlg.m_ofn.lpstrInitial Dir = penDrive;
fileDlg.m_ofn.lpstrDefExt = _T("pdf");
fileDlg.m_ofn.Flags |= OFN_NOCHANGEDIR;
Now the problem is, if the user types abc.bin file in the filename edit box on CfileDialog, and clicks on open , it tries to open that file name with that extension. So I want to disable the FileName edit box and allow the user to select & open only files from the displayed list in CFileDialog.
Can you please let me know how to disable the FileName edit box in CFileDialog.
Thanks
I am working in VC++. I'm using CFileDialog class for opening files. Here I am allowing the user to open only text and pdf files by providing a filter in the constructor as shown below.
char szFilter[64];
memset(szFilter, 0, sizeof(szFilter));
strcpy(szFilter, "JobDoc File(*.pdf;*.txt)");
strcpy(&szFilter[strlen(sz
CFileDialog fileDlg(TRUE, _T("*.pdf"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR, szFilter);
fileDlg.m_ofn.lpstrFilter = szFilter;
fileDlg.m_ofn.lpstrTitle = "Browse Job Options File";
fileDlg.m_ofn.lpstrInitial
fileDlg.m_ofn.lpstrDefExt = _T("pdf");
fileDlg.m_ofn.Flags |= OFN_NOCHANGEDIR;
Now the problem is, if the user types abc.bin file in the filename edit box on CfileDialog, and clicks on open , it tries to open that file name with that extension. So I want to disable the FileName edit box and allow the user to select & open only files from the displayed list in CFileDialog.
Can you please let me know how to disable the FileName edit box in CFileDialog.
Thanks
I will suggest you to look at followin thread abt how to customize CFileFialog..
https://www.experts-exchange.com/questions/10009026/Customization-of-File-Open-Dialog.html
derive your own class from CFileDialog and on InitDialog of your class disable / enable controls. stc2, stc3, edt1,lst1,cmb1 are control ids of CFileDialog . Refer above for more.
-MAHESH
https://www.experts-exchange.com/questions/10009026/Customization-of-File-Open-Dialog.html
derive your own class from CFileDialog and on InitDialog of your class disable / enable controls. stc2, stc3, edt1,lst1,cmb1 are control ids of CFileDialog . Refer above for more.
-MAHESH
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Mahesh..my problem is solved..
-MAHESH