filipecorreia
asked on
Saving data when application exits
the aim is to save (to file) some data when the application exits.
I want this to happen even if windows terminates the app when
windows is shutdown. Perhaps I could catch the quit message sent
to the app but I don't have any idea on how to do that.
Thanks in advance
Filipe Correia
I want this to happen even if windows terminates the app when
windows is shutdown. Perhaps I could catch the quit message sent
to the app but I don't have any idea on how to do that.
Thanks in advance
Filipe Correia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
not the OnClose-event,
the OnCloseQuery-Event is meant
;-)
the OnCloseQuery-Event is meant
;-)
If windows terminates the app when windows is shutdown app there comes the message WM_QUERYENDSESSION
But even in the case of a windows shutdown the OnCloseQuery event should still be fired - Kretzschmar is correct.
GL
Mike
GL
Mike
Also, I was reading a few of the TI's on Borland's website the other day and they stated that if you do have a handler for the OnCloseQuery and set the value of CanClose to False, Windows shutdown can be halted.
I'd put my code in the OnDestroy event handler.
It's sure to get called there, whatever the reason for
termination.
rondi
It's sure to get called there, whatever the reason for
termination.
rondi
ASKER
I have an option in my app that terminates the app by doing:
Application.Terminate()
When I do that the OnCloseQuery isn't trigered.
To solve this I tried subtitute this code by:
Form1->Close();
and now everything seems to be working fine(I'll test it some more times).
Do you predict any sort of problem that may hapen by doing this?
rondi: I will try your suggestion but I haven't tried it yet.
Filipe Correia
Application.Terminate()
When I do that the OnCloseQuery isn't trigered.
To solve this I tried subtitute this code by:
Form1->Close();
and now everything seems to be working fine(I'll test it some more times).
Do you predict any sort of problem that may hapen by doing this?
rondi: I will try your suggestion but I haven't tried it yet.
Filipe Correia
I suggest to use the Close, rather than Terminate or HALT - as these are not polite ways to end your application !
ASKER
Hi
rondi: An EAccessViolation happens if I use the OnDestroy event. I don't know why!
I'll use the onCloseQuery event. My app seems to be working ok until now.
Thanks to you all
Filipe Correia
rondi: An EAccessViolation happens if I use the OnDestroy event. I don't know why!
I'll use the onCloseQuery event. My app seems to be working ok until now.
Thanks to you all
Filipe Correia
ASKER
Filipe Correia