]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxCloseEvent}}\label{wxcloseevent} |
2 | ||
3 | This event class contains information about window and session close events. | |
4 | ||
f4fcc291 JS |
5 | The handler function for EVT\_CLOSE is called when the user has tried to close a a frame |
6 | or dialog box using the window manager (X) or system menu (Windows). It is | |
7 | called via the \helpref{wxWindow::Close}{wxwindowclose} function, so | |
8 | that the application can also invoke the handler programmatically. | |
9 | ||
10 | You should check whether the application is forcing the deletion of the window | |
11 | using \helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto}. If this is {\tt FALSE}, | |
12 | you {\it must} destroy the window using \helpref{wxWindow::Destroy}{wxwindowdestroy}. | |
13 | If the return value is TRUE, it is up to you whether you respond by destroying the window. | |
14 | ||
15 | If you don't destroy the window, you should call \helpref{wxCloseEvent::Veto}{wxcloseeventveto} to | |
16 | let the calling code know that you did not destroy the window. This allows the \helpref{wxWindow::Close}{wxwindowclose} function | |
17 | to return {\tt TRUE} or {\tt FALSE} depending on whether the close instruction was honoured or not. | |
18 | ||
a660d684 KB |
19 | \wxheading{Derived from} |
20 | ||
21 | \helpref{wxEvent}{wxevent} | |
22 | ||
954b8ae6 JS |
23 | \wxheading{Include files} |
24 | ||
25 | <wx/event.h> | |
26 | ||
a660d684 KB |
27 | \wxheading{Event table macros} |
28 | ||
29 | To process a close event, use these event handler macros to direct input to member | |
30 | functions that take a wxCloseEvent argument. | |
31 | ||
32 | \twocolwidtha{7cm} | |
33 | \begin{twocollist}\itemsep=0pt | |
387a3b02 JS |
34 | \twocolitem{{\bf EVT\_CLOSE(func)}}{Process a close event, supplying the member function. This |
35 | event applies to wxFrame and wxDialog classes.} | |
36 | \twocolitem{{\bf EVT\_QUERY\_END\_SESSION(func)}}{Process a query end session event, supplying the member function. | |
37 | This event applies to wxApp only.} | |
2432b92d | 38 | \twocolitem{{\bf EVT\_END\_SESSION(func)}}{Process an end session event, supplying the member function. |
387a3b02 | 39 | This event applies to wxApp only.} |
a660d684 KB |
40 | \end{twocollist}% |
41 | ||
42 | \wxheading{See also} | |
43 | ||
a660d684 | 44 | \helpref{wxWindow::Close}{wxwindowclose},\rtfsp |
da36f544 | 45 | \helpref{wxApp::OnQueryEndSession}{wxapponqueryendsession},\rtfsp |
4d5a0f67 GD |
46 | %% GD: OnXXX functions are not documented |
47 | %%\helpref{wxApp::OnEndSession}{wxapponendsession},\rtfsp | |
a660d684 KB |
48 | \helpref{Window deletion overview}{windowdeletionoverview} |
49 | ||
50 | \latexignore{\rtfignore{\wxheading{Members}}} | |
51 | ||
52 | \membersection{wxCloseEvent::wxCloseEvent} | |
53 | ||
54 | \func{}{wxCloseEvent}{\param{WXTYPE}{ commandEventType = 0}, \param{int}{ id = 0}} | |
55 | ||
56 | Constructor. | |
57 | ||
387a3b02 JS |
58 | \membersection{wxCloseEvent::CanVeto}\label{wxcloseeventcanveto} |
59 | ||
60 | \func{bool}{CanVeto}{\void} | |
61 | ||
62 | Returns TRUE if you can veto a system shutdown or a window close event. | |
63 | Vetoing a window close event is not possible if the calling code wishes to | |
64 | force the application to exit, and so this function must be called to check this. | |
65 | ||
a660d684 KB |
66 | \membersection{wxCloseEvent::GetLoggingOff}\label{wxcloseeventgetloggingoff} |
67 | ||
68 | \constfunc{bool}{GetLoggingOff}{\void} | |
69 | ||
70 | Returns TRUE if the user is logging off. | |
71 | ||
72 | \membersection{wxCloseEvent::GetSessionEnding}\label{wxcloseeventgetsessionending} | |
73 | ||
74 | \constfunc{bool}{GetSessionEnding}{\void} | |
75 | ||
76 | Returns TRUE if the session is ending. | |
77 | ||
78 | \membersection{wxCloseEvent::GetForce}\label{wxcloseeventgetforce} | |
79 | ||
387a3b02 | 80 | \constfunc{bool}{GetForce}{\void} |
a660d684 KB |
81 | |
82 | Returns TRUE if the application wishes to force the window to close. | |
387a3b02 JS |
83 | This will shortly be obsolete, replaced by CanVeto. |
84 | ||
85 | \membersection{wxCloseEvent::SetCanVeto}\label{wxcloseeventsetcanveto} | |
86 | ||
87 | \func{void}{SetCanVeto}{\param{bool}{ canVeto}} | |
88 | ||
89 | Sets the 'can veto' flag. | |
90 | ||
91 | \membersection{wxCloseEvent::SetForce}\label{wxcloseeventsetforce} | |
92 | ||
93 | \constfunc{void}{SetForce}{\param{bool}{ force}} | |
94 | ||
95 | Sets the 'force' flag. | |
96 | ||
97 | \membersection{wxCloseEvent::SetLoggingOff}\label{wxcloseeventsetloggingoff} | |
98 | ||
99 | \constfunc{void}{SetLoggingOff}{\param{bool}{ loggingOff}} | |
100 | ||
101 | Sets the 'logging off' flag. | |
a660d684 KB |
102 | |
103 | \membersection{wxCloseEvent::Veto}\label{wxcloseeventveto} | |
104 | ||
387a3b02 JS |
105 | \func{void}{Veto}{\param{bool}{ veto = TRUE}} |
106 | ||
107 | Call this from your event handler to veto a system shutdown or to signal | |
108 | to the calling application that a window close did not happen. | |
a660d684 | 109 | |
387a3b02 JS |
110 | You can only veto a shutdown if \helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto} returns |
111 | TRUE. | |
a660d684 KB |
112 | |
113 |