Solved

Overriding OnFileOpen?

Posted on 2000-03-06
6
466 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 56
Best tools for Backup and restore of Wordpress site 6 55
JQuery serialize and unserialize 8 51
Way to decrease size of apk file 9 45
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

17 Experts available now in Live!

Get 1:1 Help Now