[msw 2.8.7] Problem saving application settings when system
is shut down
Eric Jensen
ml at j-dev.de
Wed Apr 23 06:47:29 PDT 2008
Hello Vadim,
Friday, April 18, 2008, 2:23:49 AM, you wrote:
EJ>> Your second idea worked though. Here is what we have now:
EJ>>
EJ>> void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
EJ>> {
EJ>> //if(GetTopWindow()) GetTopWindow()->Close(true);
EJ>> // Windows will terminate the process soon after we
EJ>> // return from WM_ENDSESSION handler anyhow, so make
EJ>> // sure we at least execute our cleanup code before
EJ>>
EJ>> if(wxTopLevelWindows.GetCount()>0) {
EJ>> wxTopLevelWindows[0]->SetHWND(NULL);
EJ>> }
EJ>>
EJ>> const int rc = OnExit();
EJ>> wxEntryCleanup();
EJ>>
EJ>> // calling exit() instead of ExitProcess() or not doing
EJ>> // anything at all and being killed by Windows has the
EJ>> // advantage of executing the dtors of global objects
EJ>> exit(rc);
EJ>> }
EJ>>
EJ>> Saving the old HWND and calling ::DestroyWindow() on it later does not
EJ>> work (leads to a crash).
EJ>>
EJ>> I'll do some more testing tomorrow.
VZ> Please let me know if you discover any problems with this or whether I
VZ> should go ahead and apply it.
sorry for the late reply, only now had time to do some more testing.
The above code seems to work fine. It still feels a bit like
a dirty hack, but i guess that's what you need to circumvent Windows
behavior sometimes ;)
Thanks for your help.
Regards, Eric
More information about the wx-users
mailing list