I created a text editor know I have 2 problems
1. I want that when I close the program or the file the program ask me if I want to ave the file or not.
2. When I've changed nothing he don't do that.
I created a text editor know I have 2 problems
1. I want that when I close the program or the file the program ask me if I want to ave the file or not.
2. When I've changed nothing he don't do that.
One solution is MFC's SetModified(). Call that function in the document class.
Kuphryn
If your not using MFC, you can use the same idea. Have a boolean flag called "Changed" or similar.
When you create a new file, then obviously, anything they type is new so they should be asked, hence, new file, set "Changed" to TRUE.
When you open an existing file, they have not actually changed anything, so set it to FALSE. If, using your program they do anything to change the file, set "Changed" to TRUE.
Now, when you come to exit, check the flag, if it is TRUE ask them if they want to save, if it is FALSE, don't bother.
This is, of course, highly simplistic. It would not work if they change something, and then change it back again, but it will get you started.
A way to get round the change/unchange problem is to calculate a file checksum when you open the file, and then recalculate the checksum when you do the save, if the checksums are the same, no save is necessary, if they are different, ask them.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.