Solved

When FileOpen did not update with the new file

Posted on 1999-01-29
2
173 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

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

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

22 Experts available now in Live!

Get 1:1 Help Now