Solved

Overriding OnFileOpen?

Posted on 2000-03-06
6
452 Views
Last Modified: 2013-11-20
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!
0
Comment
Question by:sixstring
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 100 total points
Comment Utility
Hi,

Do

static char BASED_CODE szFilt[] = "Configuration File (*.SUM)|*.SUM||";
CFileDialog dlg(TRUE,"SUM","*.SUM",OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ,szFilt);

Then

dlg.DoModal();

Thats it .

VinExpert
0
 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
Hi,

static char BASED_CODE szFilt[] = "Configuration File (*.SUM)|*.SUM||";
CFileDialog dlg(TRUE,"SUM","*.SUM",OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ,szFilt);
//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
0
 

Author Comment

by:sixstring
Comment Utility
Finally--someone fully understood one of my problems and answered it exactly as I needed!  Thanks!!
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
Hi,

Why man, what happened to u? :). In EE almost all questions will be answered!!!.

VinExpert
0
 

Author Comment

by:sixstring
Comment Utility
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.)
0
 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
Hi,


Where is the memory leak?. I dont think there is anything wrong with that solution.

VinExpert
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now