Save as..
-
Hi. In the MDI program that I've created, after I have "save as..", the title bar changed to the filename that I put in the save as dialog. How can I retain the old filename in the title bar?
The title bar is set with SetWindowText. It's set by the framework, you'd need to change it after this occurs, but the thing is, the filename is obviously being saved in a member variable, if you change the frame text without changing this value, clicking save won't do what you'd expect. So, I'd recommend stepping into the MFC code to work out the stuff that happens in a save as that you want to reverse.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi. In the MDI program that I've created, after I have "save as..", the title bar changed to the filename that I put in the save as dialog. How can I retain the old filename in the title bar?
Hi Aint, You can overwrite SetTitle() in your CDocument derived class. This Method will be called after Sav'ing and Save As'ing.
-
Hi. In the MDI program that I've created, after I have "save as..", the title bar changed to the filename that I put in the save as dialog. How can I retain the old filename in the title bar?
This is because after "saving as" you have your new file as active file/document in your app. One solution is already above, but you can make another thing (only if the old file was already saved, if new document won't be possible). You can override messages to save as.. a file, and just after the file is saved call OnCloseDoc () and OpenDocument () with the name of the old file. Then you will have the new copy of your file "saved as" but still continue working with the original file. If the project is a new project... you can make a call to Serialize first to save the things in a default file, then call the save as and then the same as before. But the fact is that 95% of the applications/programms work in that way. You always have active the file with the last save. I mean... if you open file1 and do some changes, then save as file2. You will have the file1 without changes in the HD, you will see the changes made in the file2 (and this one will be the active document automatically) and any posterior change will go automatically to file2, as long you don't open specifically the file1 another time.
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
-
Hi. In the MDI program that I've created, after I have "save as..", the title bar changed to the filename that I put in the save as dialog. How can I retain the old filename in the title bar?
This is because after "saving as" you have your new file as active file/document in your app. One solution is already above, but you can make another thing. You can override messages of "save as.." in a file, and just after the file is saved call OnCloseDoc () and OpenDocument () with the name of the old file. Then you will have the new copy of your file "saved as" but still continue working with the original file. If the project is a new project... you can make a call to Serialize first to save the things in a default file, then call the save as and then the same as before. But the fact is that 95% of the applications/programms work in that way. You always have active the file with the last save. I mean... if you open file1 and do some changes, then save as file2. You will have the file1 without changes in the HD, you will see the changes made in the file2 (and this one will be the active document automatically) and any posterior change will go automatically to file2, as long you don't open specifically the file1 another time.
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?