?
Solved

Overriding OnFileOpen?

Posted on 2000-03-06
6
Medium Priority
?
498 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 400 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

765 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