?
Solved

When FileOpen did not update with the new file

Posted on 1999-01-29
2
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
jim_pettinato earned 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 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