Solved

When FileOpen did not update with the new file

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

770 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