Bool OnClose(void)
Sent to the frame when the user has tried to close the window using the window manager (X) or system menu (Windows). If TRUE is returned by OnClose, the frame will be deleted by the system, otherwise the attempt will be ignored. Derive your own class to handle this message; the default handler returns FALSE.
This member is a good place to delete other frames which are conceptually or actually subframes of this frame, since if all frames are not deleted, the application cannot exit. This is the top-level OnClose handler for the 'hello' demo:
Bool MyFrame::OnClose(void) { if (subframe) delete subframe; return TRUE; }When quitting the application from inside the application, for example from a menu item, call the frame's OnClose member before deleting the frame. wxWindows then causes the application to exit without further ado. For example:
// Intercept menu commands void MyFrame::OnMenuCommand(int id) { switch (id) { ... case HELLO_QUIT: { OnClose(); delete this; break; } ... } }