set_window_close_hook(3)

NAME
set_window_close_hook

SYNOPSIS
#include <allegro.h>

void set_window_close_hook(void (*proc)());

DESCRIPTION
On platforms that have a close button, this routine installs a hook function to handle the close event. In other words, when the user clicks the close button on your program's window, the function you specify here will be called. You can use this function to display a box offering to save data or checking that the user really wants to exit, or you can use it just to save config data, free memory and exit. This function should not generally attempt to exit the program or save any data itself. The function could be called at any time, and there is usually a risk of trying to save when the data are invalid. Instead, you should set a flag during this function, and test the flag on a regular basis in the main program. Pass NULL to this function to restore the close button's default functionality. On Windows and BeOS, the following message will appear: Warning: forcing program shutdown may lead to data loss and unexpected results. It is preferable to use the exit command inside the window. Proceed anyway? [Yes] [No] This message will be translated into your selected language if a translation is available in language.dat (see get_config_text()). If the user clicks [Yes], the program will exit immediately in the same style as Ctrl+Alt+End (see three_finger_flag). In other operating systems, the program will exit immediately without prompting the user. Note that Allegro cannot intercept the close button of a DOS box in Windows.

SEE ALSO
set_window_close_button(3), set_window_title(3), get_config_text(3), three_finger_flag(3)