Solved

Overriding OnFileOpen?

Posted on 2000-03-06
6
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 100 total points
ID: 2590275
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
ID: 2590281
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
ID: 2592529
Finally--someone fully understood one of my problems and answered it exactly as I needed!  Thanks!!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:VinExpert
ID: 2594446
Hi,

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

VinExpert
0
 

Author Comment

by:sixstring
ID: 2597045
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
ID: 2599077
Hi,


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

VinExpert
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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