Solved

Overriding OnFileOpen?

Posted on 2000-03-06
6
473 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to monitor remote shell execution on linux 9 100
countEvens challenge 2 98
only14 challenge 19 75
Modbus - whats the maximum I can store in one register? 4 79
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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