]>
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 | 5 | The handler function for EVT\_CLOSE is called when the user has tried to close a a frame |
649a48a2 VZ |
6 | or dialog box using the window manager (X) or system menu (Windows). It can |
7 | also be invoked by the application itself programmatically, for example by | |
8 | calling the \helpref{wxWindow::Close}{wxwindowclose} function. | |
f4fcc291 JS |
9 | |
10 | You should check whether the application is forcing the deletion of the window | |
cc81d32f | 11 | using \helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto}. If this is {\tt false}, |
f4fcc291 | 12 | you {\it must} destroy the window using \helpref{wxWindow::Destroy}{wxwindowdestroy}. |
cc81d32f | 13 | If the return value is true, it is up to you whether you respond by destroying the window. |
f4fcc291 JS |
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 | |
cc81d32f | 17 | to return {\tt true} or {\tt false} depending on whether the close instruction was honoured or not. |
f4fcc291 | 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 | ||
a7af285d VZ |
27 | \wxheading{Library} |
28 | ||
29 | \helpref{wxCore}{librarieslist} | |
30 | ||
a660d684 KB |
31 | \wxheading{Event table macros} |
32 | ||
33 | To process a close event, use these event handler macros to direct input to member | |
34 | functions that take a wxCloseEvent argument. | |
35 | ||
36 | \twocolwidtha{7cm} | |
37 | \begin{twocollist}\itemsep=0pt | |
387a3b02 JS |
38 | \twocolitem{{\bf EVT\_CLOSE(func)}}{Process a close event, supplying the member function. This |
39 | event applies to wxFrame and wxDialog classes.} | |
40 | \twocolitem{{\bf EVT\_QUERY\_END\_SESSION(func)}}{Process a query end session event, supplying the member function. | |
41 | This event applies to wxApp only.} | |
2432b92d | 42 | \twocolitem{{\bf EVT\_END\_SESSION(func)}}{Process an end session event, supplying the member function. |
387a3b02 | 43 | This event applies to wxApp only.} |
a660d684 KB |
44 | \end{twocollist}% |
45 | ||
46 | \wxheading{See also} | |
47 | ||
a660d684 | 48 | \helpref{wxWindow::Close}{wxwindowclose},\rtfsp |
4d5a0f67 GD |
49 | %% GD: OnXXX functions are not documented |
50 | %%\helpref{wxApp::OnEndSession}{wxapponendsession},\rtfsp | |
a660d684 KB |
51 | \helpref{Window deletion overview}{windowdeletionoverview} |
52 | ||
53 | \latexignore{\rtfignore{\wxheading{Members}}} | |
54 | ||
4bcfcdef | 55 | |
f510b7b2 | 56 | \membersection{wxCloseEvent::wxCloseEvent}\label{wxcloseeventctor} |
a660d684 KB |
57 | |
58 | \func{}{wxCloseEvent}{\param{WXTYPE}{ commandEventType = 0}, \param{int}{ id = 0}} | |
59 | ||
60 | Constructor. | |
61 | ||
4bcfcdef | 62 | |
387a3b02 JS |
63 | \membersection{wxCloseEvent::CanVeto}\label{wxcloseeventcanveto} |
64 | ||
65 | \func{bool}{CanVeto}{\void} | |
66 | ||
cc81d32f | 67 | Returns true if you can veto a system shutdown or a window close event. |
387a3b02 JS |
68 | Vetoing a window close event is not possible if the calling code wishes to |
69 | force the application to exit, and so this function must be called to check this. | |
70 | ||
4bcfcdef | 71 | |
a660d684 KB |
72 | \membersection{wxCloseEvent::GetLoggingOff}\label{wxcloseeventgetloggingoff} |
73 | ||
74 | \constfunc{bool}{GetLoggingOff}{\void} | |
75 | ||
4bcfcdef VZ |
76 | Returns true if the user is just logging off or false if the system is |
77 | shutting down. This method can only be called for end session and query end | |
78 | session events, it doesn't make sense for close window event. | |
79 | ||
a660d684 | 80 | |
387a3b02 JS |
81 | \membersection{wxCloseEvent::SetCanVeto}\label{wxcloseeventsetcanveto} |
82 | ||
83 | \func{void}{SetCanVeto}{\param{bool}{ canVeto}} | |
84 | ||
85 | Sets the 'can veto' flag. | |
86 | ||
4bcfcdef | 87 | |
387a3b02 JS |
88 | \membersection{wxCloseEvent::SetForce}\label{wxcloseeventsetforce} |
89 | ||
90 | \constfunc{void}{SetForce}{\param{bool}{ force}} | |
91 | ||
92 | Sets the 'force' flag. | |
93 | ||
4bcfcdef | 94 | |
387a3b02 JS |
95 | \membersection{wxCloseEvent::SetLoggingOff}\label{wxcloseeventsetloggingoff} |
96 | ||
97 | \constfunc{void}{SetLoggingOff}{\param{bool}{ loggingOff}} | |
98 | ||
99 | Sets the 'logging off' flag. | |
a660d684 | 100 | |
4bcfcdef | 101 | |
a660d684 KB |
102 | \membersection{wxCloseEvent::Veto}\label{wxcloseeventveto} |
103 | ||
cc81d32f | 104 | \func{void}{Veto}{\param{bool}{ veto = true}} |
387a3b02 JS |
105 | |
106 | Call this from your event handler to veto a system shutdown or to signal | |
107 | to the calling application that a window close did not happen. | |
a660d684 | 108 | |
387a3b02 | 109 | You can only veto a shutdown if \helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto} returns |
cc81d32f | 110 | true. |
a660d684 KB |
111 | |
112 |