sixstring
asked on
Overriding OnFileOpen?
I have an SDI application. It opens binary files, typically with an extension .WTD.
I want to add a File | Import menu item. The subsequent Open dialog box needs to show only files of a specific type (.SUM). When the user selects the desired file, I need to read in the data (it will be a text file) and merge it with the data already in the open document.
I have a menu item with generates an ID_FILE_IMPORT command. This calls my function OnFileImport ().
Now, how do I get this function to bring up the Open File dialog appropriately (with the .SUM file filter), then read in the text info so I can start merging it?
Working code especially appreciated! (I'm kinda new to MFC.)
Thanks!
I want to add a File | Import menu item. The subsequent Open dialog box needs to show only files of a specific type (.SUM). When the user selects the desired file, I need to read in the data (it will be a text file) and merge it with the data already in the open document.
I have a menu item with generates an ID_FILE_IMPORT command. This calls my function OnFileImport ().
Now, how do I get this function to bring up the Open File dialog appropriately (with the .SUM file filter), then read in the text info so I can start merging it?
Working code especially appreciated! (I'm kinda new to MFC.)
Thanks!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Finally--someone fully understood one of my problems and answered it exactly as I needed! Thanks!!
Hi,
Why man, what happened to u? :). In EE almost all questions will be answered!!!.
VinExpert
Why man, what happened to u? :). In EE almost all questions will be answered!!!.
VinExpert
ASKER
Usually, I get an answer that touches the edges of the problem without getting it directly. Typically, I have to use that as a starting point to fumble around until I figure it out myself.
(Actually, the solution you gave me now causes a Memory Leak warning, which I've been unable to solve. I'm worried it might be triggering a problem that is actually happening upstream somewhere.)
(Actually, the solution you gave me now causes a Memory Leak warning, which I've been unable to solve. I'm worried it might be triggering a problem that is actually happening upstream somewhere.)
Hi,
Where is the memory leak?. I dont think there is anything wrong with that solution.
VinExpert
Where is the memory leak?. I dont think there is anything wrong with that solution.
VinExpert
static char BASED_CODE szFilt[] = "Configuration File (*.SUM)|*.SUM||";
CFileDialog dlg(TRUE,"SUM","*.SUM",OFN
//Now pop up the dialog
if (dlg.DoModal() == IDOK)
{
CString strFilePath = dlg.GetPathName();
//strFilePath will contain the path for the file.
//Open that file and read the data.
}
Hope this helps.
VinExpert