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. 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 conflict with the main thread of the program. Instead, you should set a flag during this function, and test it on a regular basis in the main loop of the 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)