From 195be56dca4c6d9d25ec824fdcbdfa3b015a44ba Mon Sep 17 00:00:00 2001 From: Francesco Montorsi Date: Mon, 24 Nov 2008 00:01:37 +0000 Subject: [PATCH] provide an example implementation of wxCloseEvent handler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/event.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/interface/wx/event.h b/interface/wx/event.h index 88f3714d07..2db11fddb5 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -2861,6 +2861,27 @@ public: This allows the wxWindow::Close function to return @true or @false depending on whether the close instruction was honoured or not. + Example of a wxCloseEvent handler: + + @code + void MyFrame::OnClose(wxCloseEvent& event) + { + if ( event.CanVeto() && m_bFileNotSaved ) + { + if ( wxMessageBox("The file has not been saved... continue closing?", + "Please confirm", + wxICON_QUESTION | wxYES_NO) != wxYES ) + { + event.Veto(); + return; + } + } + + Destroy(); // you may also do: event.Skip(); + // since the default event handler does call Destroy(), too + } + @endcode + The EVT_END_SESSION event is slightly different as it is sent by the system when the user session is ending (e.g. because of log out or shutdown) and so all windows are being forcefully closed. At least under MSW, after the -- 2.45.2