\helpref{wxWindow::OnIdle}{wxwindowonidle}, \helpref{wxIdleEvent}{wxidleevent},\rtfsp
\helpref{wxWindow::SendIdleEvents}{wxappsendidleevents}
+\membersection{wxApp::OnEndSession}\label{wxapponendsession}
+
+\func{void}{OnEndSession}{\param{wxCloseEvent\& }{event}}
+
+This is an event handler function called when the operating system or GUI session is
+about to close down. The application has a chance to silently save information,
+and can optionally close itself.
+
+Use the EVT\_END\_SESSION event table macro to handle query end session events.
+
+The default handler calls \helpref{wxWindow::Close}{wxwindowclose} with a TRUE argument
+(forcing the application to close itself silently).
+
+\wxheading{Remarks}
+
+Under X, OnEndSession is called in response to the 'die' event.
+
+Under Windows, OnEndSession is called in response to the WM\_ENDSESSION message.
+
+\wxheading{See also}
+
+\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
+\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
+\helpref{wxCloseEvent}{wxcloseevent},\rtfsp
+\helpref{wxApp::OnQueryEndSession}{wxappqueryonendsession}
+
\membersection{wxApp::OnInit}\label{wxapponinit}
\func{bool}{OnInit}{\void}
Return TRUE to continue processing, FALSE to exit the application.
-\membersection{wxApp::Pending}\label{wxapppending}
+\membersection{wxApp::OnQueryEndSession}\label{wxapponqueryendsession}
-\func{bool}{Pending}{\void}
+\func{void}{OnQueryEndSession}{\param{wxCloseEvent\& }{event}}
-Returns TRUE if unprocessed events are in the window system event queue
-(MS Windows and Motif).
+This is an event handler function called when the operating system or GUI session is
+about to close down. Typically, an application will try to save unsaved documents
+at this point.
+
+If \helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto} returns TRUE, the application
+is allowed to veto the shutdown by calling \helpref{wxCloseEvent::Veto}{wxcloseeventveto}.
+The application might veto the shutdown after prompting for documents to be saved, and the
+user has cancelled the save.
+
+Use the EVT\_QUERY\_END\_SESSION event table macro to handle query end session events.
+
+You should check whether the application is forcing the deletion of the window
+using \helpref{wxCloseEvent::GetForce}{wxcloseeventgetforce}. If this is TRUE,
+destroy the window using \helpref{wxWindow::Destroy}{wxwindowdestroy}.
+If not, it is up to you whether you respond by destroying the window.
+
+The default handler calls \helpref{wxWindow::Close}{wxwindowclose} on the top-level window,
+and vetoes the shutdown if Close returns FALSE. This will be sufficient for many applications.
+
+\wxheading{Remarks}
+
+Under X, OnQueryEndSession is called in response to the 'save session' event.
+
+Under Windows, OnQueryEndSession is called in response to the WM\_QUERYENDSESSION message.
\wxheading{See also}
-\helpref{wxApp::Dispatch}{wxappdispatch}
+\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
+\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
+\helpref{wxCloseEvent}{wxcloseevent},\rtfsp
+\helpref{wxApp::OnEndSession}{wxapponendsession}
+
+\membersection{wxWindow::OnScroll}\label{wxwindowonscroll}
\membersection{wxApp::ProcessMessage}\label{wxappprocessmessage}
}
\end{verbatim}
+\membersection{wxApp::Pending}\label{wxapppending}
+
+\func{bool}{Pending}{\void}
+
+Returns TRUE if unprocessed events are in the window system event queue
+(MS Windows and Motif).
+
+\wxheading{See also}
+
+\helpref{wxApp::Dispatch}{wxappdispatch}
+
\membersection{wxApp::SendIdleEvents}\label{wxappsendidleevents}
\func{bool}{SendIdleEvents}{\void}
\twocolwidtha{7cm}
\begin{twocollist}\itemsep=0pt
-\twocolitem{{\bf EVT\_CLOSE(func)}}{Process a close event, supplying the member function.}
+\twocolitem{{\bf EVT\_CLOSE(func)}}{Process a close event, supplying the member function. This
+event applies to wxFrame and wxDialog classes.}
+\twocolitem{{\bf EVT\_QUERY\_END\_SESSION(func)}}{Process a query end session event, supplying the member function.
+This event applies to wxApp only.}
+\twocolitem{{\bf EVT\__END\_SESSION(func)}}{Process an end session event, supplying the member function.
+This event applies to wxApp only.}
\end{twocollist}%
\wxheading{See also}
\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
+\helpref{wxApp::OnQueryEndSession}{wxappqueryendsession},\rtfsp
+\helpref{wxApp::OnEndSession}{wxappendsession},\rtfsp
\helpref{Window deletion overview}{windowdeletionoverview}
\latexignore{\rtfignore{\wxheading{Members}}}
Constructor.
+\membersection{wxCloseEvent::CanVeto}\label{wxcloseeventcanveto}
+
+\func{bool}{CanVeto}{\void}
+
+Returns TRUE if you can veto a system shutdown or a window close event.
+Vetoing a window close event is not possible if the calling code wishes to
+force the application to exit, and so this function must be called to check this.
+
\membersection{wxCloseEvent::GetLoggingOff}\label{wxcloseeventgetloggingoff}
\constfunc{bool}{GetLoggingOff}{\void}
\membersection{wxCloseEvent::GetForce}\label{wxcloseeventgetforce}
-\constfunc{void}{GetForce}{\void}
+\constfunc{bool}{GetForce}{\void}
Returns TRUE if the application wishes to force the window to close.
+This will shortly be obsolete, replaced by CanVeto.
+
+\membersection{wxCloseEvent::SetCanVeto}\label{wxcloseeventsetcanveto}
+
+\func{void}{SetCanVeto}{\param{bool}{ canVeto}}
+
+Sets the 'can veto' flag.
+
+\membersection{wxCloseEvent::SetForce}\label{wxcloseeventsetforce}
+
+\constfunc{void}{SetForce}{\param{bool}{ force}}
+
+Sets the 'force' flag.
+
+\membersection{wxCloseEvent::SetLoggingOff}\label{wxcloseeventsetloggingoff}
+
+\constfunc{void}{SetLoggingOff}{\param{bool}{ loggingOff}}
+
+Sets the 'logging off' flag.
\membersection{wxCloseEvent::Veto}\label{wxcloseeventveto}
-\func{void}{Veto}{\void}
+\func{void}{Veto}{\param{bool}{ veto = TRUE}}
+
+Call this from your event handler to veto a system shutdown or to signal
+to the calling application that a window close did not happen.
-Call this from your event handler to veto a system shutdown.
+You can only veto a shutdown if \helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto} returns
+TRUE.
\helpref{wxWindow::Destroy}{wxwindowdestroy},\rtfsp
\helpref{wxCloseEvent}{wxcloseevent}
+\membersection{wxWindow::ConvertDialogToPixels}\label{wxwindowconvertdialogtopixels}
+
+\func{wxPoint}{ConvertDialogToPixels}{\param{const wxPoint\&}{ pt}}
+
+\func{wxSize}{ConvertDialogToPixels}{\param{const wxSize\&}{ sz}}
+
+Converts a point or size from dialog units to pixels.
+
+For the x dimension, the dialog units are multiplied by the average character width
+and then divided by 4.
+
+For the y dimension, the dialog units are multiplied by the average character height
+and then divided by 8.
+
+\wxheading{Remarks}
+
+Dialog units are used for maintaining a dialog's proportions even if the font changes.
+Dialogs created using Dialog Editor optionally use dialog units.
+
+You can also use these functions programmatically. A convenience macro is defined:
+
+{\small
+\begin{verbatim}
+#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
+\end{verbatim}
+}
+
+\wxheading{See also}
+
+\helpref{wxWindow::ConvertPixelsToDialog}{wxwindowconvertpixelstodialog}
+
+\membersection{wxWindow::ConvertPixelsToDialog}\label{wxwindowconvertpixelstodialog}
+
+\func{wxPoint}{ConvertPixelsToDialog}{\param{const wxPoint\&}{ pt}}
+
+\func{wxSize}{ConvertPixelsToDialog}{\param{const wxSize\&}{ sz}}
+
+Converts a point or size from pixels to dialog units.
+
+For the x dimension, the pixels are multiplied by 4 and then divided by the average
+character width.
+
+For the y dimension, the pixels are multipled by 8 and then divided by the average
+character height.
+
+\wxheading{Remarks}
+
+Dialog units are used for maintaining a dialog's proportions even if the font changes.
+Dialogs created using Dialog Editor optionally use dialog units.
+
+\wxheading{See also}
+
+\helpref{wxWindow::ConvertDialogToPixels}{wxwindowconvertdialogtopixels}
+
\membersection{wxWindow::Destroy}\label{wxwindowdestroy}
\func{virtual bool}{Destroy}{\void}
\wxheading{Remarks}
-Derive your own class to handle this message. The default handler returns FALSE.
+Derive your own class to handle this message. The default handler returns TRUE.
\wxheading{See also}
destroy the window using \helpref{wxWindow::Destroy}{wxwindowdestroy}.
If not, it is up to you whether you respond by destroying the window.
+(Note: GetForce is now superceded by CanVeto. So to test whether forced destruction of
+the window is required, test for the negative of CanVeto. If CanVeto returns FALSE,
+it is not possible to skip window deletion.)
+
+If you don't destroy the window, you should call \helpref{wxCloseEvent::Veto}{wxcloseeventveto} to
+let the calling code know that you did not destroy the window. This allows the \helpref{wxWindow::Close}{wxwindowclose} function
+to return TRUE or FALSE depending on whether the close instruction was honoured or not.
+
\wxheading{Remarks}
The \helpref{wxWindow::OnClose}{wxwindowonclose} virtual function remains
\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
\helpref{wxWindow::OnClose}{wxwindowonclose},\rtfsp
\helpref{wxWindow::Destroy}{wxwindowdestroy},\rtfsp
-\helpref{wxCloseEvent}{wxcloseevent}
+\helpref{wxCloseEvent}{wxcloseevent},\rtfsp
+\helpref{wxApp::OnQueryEndSession}{wxapponqueryendsession},\rtfsp
+\helpref{wxApp::OnEndSession}{wxapponendsession}
\membersection{wxWindow::OnDropFiles}\label{wxwindowondropfiles}
\helpref{wxPaintDC}{wxpaintdc},\rtfsp
\helpref{Event handling overview}{eventhandlingoverview}
-\membersection{wxWindow::OnScroll}\label{wxwindowonscroll}
-
\func{void}{OnScroll}{\param{wxScrollEvent\& }{event}}
Called when a scroll event is received from one of the window's built-in scrollbars.
#define wxID_HIGHEST 5999
// Shortcut for easier dialog-unit-to-pixel conversion
-#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixel(pt)
+#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
#ifdef __WXMSW__
// Stand-ins for Windows types, to avoid
const wxString& title, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
- bool OnClose(void);
// Extend event processing to search the document manager's event table
virtual bool ProcessEvent(wxEvent& event);
void OnExit(wxCommandEvent& event);
void OnMRUFile(wxCommandEvent& event);
+ void OnCloseWindow(wxCloseEvent& event);
protected:
wxDocManager *m_docManager;
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
~wxDocMDIChildFrame(void);
- bool OnClose(void);
// Extend event processing to search the view's event table
virtual bool ProcessEvent(wxEvent& event);
void OnActivate(wxActivateEvent& event);
+ void OnCloseWindow(wxCloseEvent& event);
inline wxDocument *GetDocument(void) const { return m_childDocument; }
inline wxView *GetView(void) const { return m_childView; }
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
~wxDocChildFrame(void);
- bool OnClose(void);
// Extend event processing to search the view's event table
virtual bool ProcessEvent(wxEvent& event);
-// void OldOnMenuCommand(int id);
void OnActivate(wxActivateEvent& event);
+ void OnCloseWindow(wxCloseEvent& event);
inline wxDocument *GetDocument(void) const { return m_childDocument; }
inline wxView *GetView(void) const { return m_childView; }
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME, const wxString& name = "frame");
- bool OnClose(void);
// Extend event processing to search the document manager's event table
virtual bool ProcessEvent(wxEvent& event);
-// void OldOnMenuCommand(int id);
wxDocManager *GetDocumentManager(void) const { return m_docManager; }
void OnExit(wxCommandEvent& event);
void OnMRUFile(wxCommandEvent& event);
+ void OnCloseWindow(wxCloseEvent& event);
protected:
wxDocManager *m_docManager;
public:
inline wxCloseEvent(wxEventType type = wxEVT_NULL, int id = 0)
- { m_eventType = type; m_sessionEnding = TRUE; m_loggingOff = TRUE; m_veto = FALSE;
- m_id = id; m_force = FALSE; }
+ { m_eventType = type; m_loggingOff = TRUE; m_veto = FALSE;
+ m_id = id; m_force = FALSE; m_canVeto = FALSE; }
- inline bool GetSessionEnding(void) const { return m_sessionEnding; }
+ inline void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
inline bool GetLoggingOff(void) const { return m_loggingOff; }
inline void Veto(bool veto = TRUE) { m_veto = veto; }
+ inline void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
+ inline bool CanVeto() const { return m_canVeto; }
inline bool GetVeto(void) const { return m_veto; }
+
+ // This is probably obsolete now, since we use CanVeto instead, in
+ // both OnCloseWindow and OnQueryEndSession.
+ // m_force == ! m_canVeto i.e., can't veto means we must force it to close.
inline void SetForce(bool force) { m_force = force; }
inline bool GetForce(void) const { return m_force; }
protected:
- bool m_sessionEnding;
bool m_loggingOff;
bool m_veto;
bool m_force;
-
+ bool m_canVeto;
};
/*
#define EVT_SIZE(func) { wxEVT_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) & func, (wxObject *) NULL },
#define EVT_MOVE(func) { wxEVT_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMoveEventFunction) & func, (wxObject *) NULL },
#define EVT_CLOSE(func) { wxEVT_CLOSE_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL },
+#define EVT_END_SESSION(func) { wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL },
+#define EVT_QUERY_END_SESSION(func) { wxEVT_QUERY_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL },
#define EVT_PAINT(func) { wxEVT_PAINT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaintEventFunction) & func, (wxObject *) NULL },
#define EVT_ERASE_BACKGROUND(func) { wxEVT_ERASE_BACKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxEraseEventFunction) & func, (wxObject *) NULL },
#define EVT_CHAR(func) { wxEVT_CHAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL },
virtual void Dispatch() ;
void OnIdle(wxIdleEvent& event);
+ void OnEndSession(wxCloseEvent& event);
+ void OnQueryEndSession(wxCloseEvent& event);
// Generic
virtual bool OnInit() { return FALSE; };
virtual void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu);
virtual void MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem);
virtual bool MSWOnClose(void);
+ // Return TRUE to end session, FALSE to veto end session.
+ virtual bool MSWOnQueryEndSession(long logOff);
+ virtual bool MSWOnEndSession(bool endSession, long logOff);
virtual bool MSWOnDestroy(void);
virtual bool MSWOnSetFocus(WXHWND wnd);
virtual bool MSWOnKillFocus(WXHWND wnd);
BEGIN_EVENT_TABLE(wxDocMDIParentFrame, wxMDIParentFrame)
EVT_MENU(wxID_EXIT, wxDocMDIParentFrame::OnExit)
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocMDIParentFrame::OnMRUFile)
+ EVT_CLOSE(wxDocMDIParentFrame::OnCloseWindow)
END_EVENT_TABLE()
wxDocMDIParentFrame::wxDocMDIParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
return TRUE;
}
-// Define the behaviour for the frame closing
-// - must delete all frames except for the main one.
-bool wxDocMDIParentFrame::OnClose(void)
+void wxDocMDIParentFrame::OnCloseWindow(wxCloseEvent& event)
{
- return m_docManager->Clear(FALSE);
+ if (m_docManager->Clear(!event.CanVeto()))
+ {
+ this->Destroy();
+ }
+ else
+ event.Veto();
}
BEGIN_EVENT_TABLE(wxDocMDIChildFrame, wxMDIChildFrame)
EVT_ACTIVATE(wxDocMDIChildFrame::OnActivate)
+ EVT_CLOSE(wxDocMDIChildFrame::OnCloseWindow)
END_EVENT_TABLE()
wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id,
m_childView->Activate(event.GetActive());
}
-bool wxDocMDIChildFrame::OnClose(void)
+void wxDocMDIChildFrame::OnCloseWindow(wxCloseEvent& event)
{
// Close view but don't delete the frame while doing so!
// ...since it will be deleted by wxWindows if we return TRUE.
if (m_childView)
{
- bool ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
+ bool ans = FALSE;
+ if (!event.CanVeto())
+ ans = TRUE; // Must delete.
+ else
+ ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
+
if (ans)
{
m_childView->Activate(FALSE);
delete m_childView;
m_childView = (wxView *) NULL;
m_childDocument = (wxDocument *) NULL;
+
+ this->Destroy();
}
-
- return ans;
+ else
+ event.Veto();
}
- else return TRUE;
+ else
+ event.Veto();
}
#endif
BEGIN_EVENT_TABLE(wxDocChildFrame, wxFrame)
EVT_ACTIVATE(wxDocChildFrame::OnActivate)
+ EVT_CLOSE(wxDocChildFrame::OnCloseWindow)
END_EVENT_TABLE()
wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title,
m_childView->Activate(event.GetActive());
}
-bool wxDocChildFrame::OnClose(void)
+void wxDocChildFrame::OnCloseWindow(wxCloseEvent& event)
{
- // Close view but don't delete the frame while doing so!
- // ...since it will be deleted by wxWindows if we return TRUE.
if (m_childView)
{
- bool ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
+ bool ans = FALSE;
+ if (!event.CanVeto())
+ ans = TRUE; // Must delete.
+ else
+ ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
+
if (ans)
{
m_childView->Activate(FALSE);
delete m_childView;
m_childView = (wxView *) NULL;
m_childDocument = (wxDocument *) NULL;
+
+ this->Destroy();
}
-
- return ans;
+ else
+ event.Veto();
}
- else return TRUE;
+ else
+ event.Veto();
}
/*
BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame)
EVT_MENU(wxID_EXIT, wxDocParentFrame::OnExit)
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocParentFrame::OnMRUFile)
+ EVT_CLOSE(wxDocParentFrame::OnCloseWindow)
END_EVENT_TABLE()
wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
// Define the behaviour for the frame closing
// - must delete all frames except for the main one.
-bool wxDocParentFrame::OnClose(void)
+void wxDocParentFrame::OnCloseWindow(wxCloseEvent& event)
{
- return m_docManager->Clear(FALSE);
+ if (m_docManager->Clear(!event.CanVeto()))
+ {
+ this->Destroy();
+ }
+ else
+ event.Veto();
}
#if wxUSE_PRINTING_ARCHITECTURE
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle)
+ EVT_END_SESSION(wxApp::OnEndSession)
+ EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
END_EVENT_TABLE()
#endif
}
}
+void wxApp::OnEndSession(wxCloseEvent& event)
+{
+ if (GetTopWindow())
+ GetTopWindow()->Close(TRUE);
+}
+
+// Default behaviour: close the application with prompts. The
+// user can veto the close, and therefore the end session.
+void wxApp::OnQueryEndSession(wxCloseEvent& event)
+{
+ if (GetTopWindow())
+ {
+ if (!GetTopWindow()->Close(!event.CanVeto()))
+ event.Veto(TRUE);
+ }
+}
+
wxLog* wxApp::CreateLogTarget()
{
return new wxLogGui;
EndModal(wxID_OK);
else
{
- SetReturnCode(wxID_OK);
- this->Show(FALSE);
+ SetReturnCode(wxID_OK);
+ this->Show(FALSE);
}
}
}
bool wxDialog::OnClose(void)
{
- // Behaviour changed in 2.0: we'll send a Cancel message by default,
+ // Behaviour changed in 2.0: we'll send a Cancel message by default,
// which may close the dialog.
// Check for looping if the Cancel event handler calls Close()
closing.Append(this);
- wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
- cancelEvent.SetEventObject( this );
- GetEventHandler()->ProcessEvent(cancelEvent);
+ wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+ cancelEvent.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(cancelEvent);
closing.DeleteObject(this);
- return FALSE;
+ return FALSE;
}
void wxDialog::OnCloseWindow(wxCloseEvent& event)
{
this->Destroy();
}
+ else
+ event.Veto(TRUE);
}
// Destroy the window (delayed, if a managed window)
{
this->Destroy();
}
+ else
+ event.Veto(TRUE);
}
bool wxFrame::OnClose(void)
case WM_QUERYENDSESSION:
{
// Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
- return MSWOnClose();
+// return MSWOnClose();
+
+ return MSWOnQueryEndSession(lParam);
+ break;
+ }
+ case WM_ENDSESSION:
+ {
+ // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
+ MSWOnEndSession((wParam != 0), lParam);
+ return 0L;
break;
}
case WM_CLOSE:
return FALSE;
}
+// Return TRUE to end session, FALSE to veto end session.
+bool wxWindow::MSWOnQueryEndSession(long logOff)
+{
+ wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1);
+ event.SetEventObject(wxTheApp);
+ event.SetCanVeto(TRUE);
+ event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
+ if ((this == wxTheApp->GetTopWindow()) && // Only send once
+ wxTheApp->ProcessEvent(event) && event.GetVeto())
+ {
+ return FALSE; // Veto!
+ }
+ else
+ {
+ return TRUE; // Don't veto
+ }
+}
+
+bool wxWindow::MSWOnEndSession(bool endSession, long logOff)
+{
+ wxCloseEvent event(wxEVT_END_SESSION, -1);
+ event.SetEventObject(wxTheApp);
+ event.SetCanVeto(FALSE);
+ event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
+ if (endSession && // No need to send if the session isn't ending
+ (this == wxTheApp->GetTopWindow()) && // Only send once
+ wxTheApp->ProcessEvent(event))
+ {
+ }
+ return TRUE;
+}
+
bool wxWindow::MSWOnDestroy(void)
{
#if WXDEBUG > 1
bool wxWindow::Close(bool force)
{
- // Let's generalise it to work the same for any window.
-/*
- if (!IsKindOf(CLASSINFO(wxDialog)) && !IsKindOf(CLASSINFO(wxFrame)))
- {
- this->Destroy();
- return TRUE;
- }
-*/
-
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
event.SetForce(force);
+ event.SetCanVeto(!force);
- return GetEventHandler()->ProcessEvent(event);
-
-/*
- if ( !force && event.GetVeto() )
- return FALSE;
-
- Show(FALSE);
-
- if (!wxPendingDelete.Member(this))
- wxPendingDelete.Append(this);
-
- return TRUE;
-*/
+ return (GetEventHandler()->ProcessEvent(event) && !event.GetVeto());
}
wxObject* wxWindow::GetChild(int number) const