Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open File Dialog

Status
Not open for further replies.

rachelason

Programmer
Jun 28, 2004
114
GB
HI! I want to get rid of All Files(*.*)from the type list when i try to open a document in an MFC program.
I had to do the same in the SaveAs which i managed to solve it by calling CFileDialog with the file types in the DOFileSave function.
But there is no DOFileOpen function to open a document with only one option(*.xtr - this is a file extension i have created through MFC).

I edited the string table, but no good.

I believe this is the code required to do it... but what i don't understand is where to add it. I tried in OnNewDocument(), serialize, etc etc.

<code>

CFileDialog ldFile1(TRUE, _T(".XTR"), NULL, OFN_HIDEREADONLY, _T("*.XTR"));
ldFile1.DoModal() ;

</code>

Any suggestion please?
Thanks
Rach
 
Not MFC related, but functions GetOpenFileName() and GetSaveFileName() could be perhaps helpfull, if I understood correctly?
 
this is how to open a common dialog open/save this is set to open and I have added the *.xtr filter for you.
Code:
CFileDialog dlg(TRUE/*Open=TRUE Save=False*/,NULL/*Filename Extension*/,"Directory Selection"/*Initial Filename*/,OFN_ENABLESIZING|OFN_EXPLORER|OFN_FILEMUSTEXIST/*Flags*/,"XTR(*.xtr)|*.xtr||"/*Filetype Filter*/,this/*parent Window*/);
if (dlg.DoModal() == IDOK)
{
    CString fileName = dlg.GetFileName();
}
O.B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top