Solved

When FileOpen did not update with the new file

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 108
iSeries FTP Exit Program 8 147
Folder Comparison 12 54
My project did see openJDK that I installed. What could be the problem 7 152
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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