Solved

When FileOpen did not update with the new file

Posted on 1999-01-29
2
172 Views
Last Modified: 2013-11-20
In my application, I open a file name "friday", and did some modification to the documents, and then I "CLEAR" the contents. I then try to FILE OPEN "Friday" again, however I did not get the "friday" document loaded into my applicaiton. How do I make sure that when SAVE or OPEN is called. It will definately save or recall the named file??
0
Comment
Question by:nicolet
2 Comments
 
LVL 1

Accepted Solution

by:
jim_pettinato earned 50 total points
ID: 1328489
By default in MFC, it appears, selecting File|Open "friday" when "friday" is already open has no effect, regardless of the state of the open document. I'm not sure what you are asking exactly, but here are some tips:

  Any time you change a document, call the document's SetModifiedFlag() method. This will assure that the document will not be closed without prompting the user to save changes.

  If you are making changes to the document and want be sure they are saved (and do not want to involve the user), you can force a file save by doing:

    doc->OnSaveDocument(doc->GetTitle());

  If you wish to overwrite the changes with the contents of the document last were written to disk, override the OnFileOpen command handler in your frame class, and close the document first by calling doc->OnCloseDocument(). If you wish to abandon any changes made, you can also SetModifiedFlag(FALSE) before
closing to avoid the user being prompted first.

If these suggestions are not what you are looking for, you're going to need to be more specific. The following would help:
1. MDI or SDI?
2. Are you using the standard Doc/View architecture?
3. Is the user to be involved in this process? When?

0
 

Author Comment

by:nicolet
ID: 1328490
It is a SDI, using Doc/View, Question is such as : user has opened a file "friday" from disk into application,user has done some changes to the contents of the current opened document that is "friday", now if user want to Open the file "friday" from disk ( as it was written previously) to the application, how can I make sure that the old "friday" file will be read, in spite of the "friday" file is the currently opened file. Your suggestion of using doc->OnCloseDocument() to close the current document make sense. However I am having some MFC technical difficulty, FILE OPEN command is in CApp.cpp file not in CDoc.cpp file, How can I get the doc pointer in CApp.cpp file, and second after I have OnCloseDocument() what do I call to Open the "friday" file?

Another question is that File can be open via FILE - OPEN also via FILE - recent file list. How should I do in order to make sure current opened file will be prompted to be closed : doc->OnCloseDocument() and also read in a pre written file from disk under both FILE OPEN or FILE recent file situation?

Thank You!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 100
Separate files macro - Errors on larger data set 18 56
sum13 challenge 24 77
sumHeights  challenge 17 61
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: 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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 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

18 Experts available now in Live!

Get 1:1 Help Now