Re: Making sure data is saved on closing application
- From: "kizmet space adventures (remove 'not.' for emailing)" <pleasedo.not.mailme@xxxxxxxxxxxxxx>
- Date: Thu, 22 Dec 2005 20:34:32 GMT
On Thu, 22 Dec 2005 15:07:08 -0500, Joseph M. Newcomer
<newcomer@xxxxxxxxxxxx> wrote:
>If you are using doc/view, which is what it sounds like, it is your responsibility to call
>CDocument::SetModified(TRUE) whenever you make a change. Otherwise, there is no way to
>know the document actually has a change.
>
It uses classes inherited from CDocument and CRecordView. What you
say applies here then?
Thanks for your help,
Ben
>One way of handling this is to make sure there is no way to modify the structure of the
>document by manipulating member variables of the CDocument class; instead, provide
>functions that modify the values, e.g.
>
>void CDocument::AddThing(Thing * p)
> {
> ...add the thing
> SetModified(TRUE);
> }
>
>this guarantees that you can't ever make a change without causing the modified flag to be
>set.
> joe
>
>On Wed, 21 Dec 2005 21:53:13 GMT, "kizmet space adventures (remove 'not.' for emailing)"
><pleasedo.not.mailme@xxxxxxxxxxxxxx> wrote:
>
>>On Tue, 20 Dec 2005 19:56:13 GMT, "kizmet space adventures (remove
>>'not.' for emailing)" <pleasedo.not.mailme@xxxxxxxxxxxxxx> wrote:
>>
>>>Hi,
>>>
>>>I have built myself the following application from 'Teach Yourself
>>>Visual C++ in 21 Days' chapter 'Day 14 - Retrieving Data from an ODBC
>>>Database'
>>>
>>>http://serghei.net/docs/programming/c++/ty%20visualC++6%2021%20days/ch14/ch14.htm
>>>
>>>The application lets you edit and add records to a database (as well
>>>as just retreive them). The application uses recordset flags in code
>>>to make sure that data is saved if you edit one record and move to
>>>another. However, there is no code to make sure new or edited data is
>>>saved when the application is exited.
>>>
>>>After having poked about, I have found the ID_APP_EXIT event which I
>>>can capture for the MainFrame class (IE it works when I select 'exit'
>>>from the drop down menu), however, I haven't managed to find any way
>>>of preventing the application from closing in order to perform an 'is
>>>the data saved?' check when the 'cross' button at the top right hand
>>>corner of the application is clicked.
>>>
>>>I was hoping I could get some help here. Is this an MFC issue - or is
>>>it a Windows API thing?
>>>
>>>Thanks
>>
>>Thanks for all of your replies. I still haven't found the right answer
>>for the application above. However, I have had a look at the example
>>application for the previous chapter in the book
>>
>>http://serghei.net/docs/programming/c++/ty%20visualC++6%2021%20days/ch13/ch13.htm
>>
>> (which essentially describes how to make a Serialized application). I
>>ran the application, and lo and behold, if data is added or changed,
>>then a warning dialog appears when the frame 'x' button is clicked.
>>Having a quick rummage through this previous chapter I can't find any
>>explicit explanation of how this happens. I guess the necessary code
>>is installed by the DECLARE_SERIAL and /or the IMPLEMENT_SERIAL
>>macros. Hmm. Perhaps I should declare the document class (for the
>>application I'm currently working on) as serializable?
>Joseph M. Newcomer [MVP]
>email: newcomer@xxxxxxxxxxxx
>Web: http://www.flounder.com
>MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Making sure data is saved on closing application
- From: Joseph M . Newcomer
- Re: Making sure data is saved on closing application
- References:
- Making sure data is saved on closing application
- From: kizmet space adventures (remove 'not.' for emailing)
- Re: Making sure data is saved on closing application
- From: kizmet space adventures (remove 'not.' for emailing)
- Re: Making sure data is saved on closing application
- From: Joseph M . Newcomer
- Making sure data is saved on closing application
- Prev by Date: Re: CFormView and Tab control
- Next by Date: Re: Making sure data is saved on closing application
- Previous by thread: Re: Making sure data is saved on closing application
- Next by thread: Re: Making sure data is saved on closing application
- Index(es):