The CanClose mechanism gives the application object, the main window, and any other windows a chance to either prepare for closing or prevent the closing from taking place.
In the end, the application object approves the closing of the application. The normal closing sequence looks like this:
- Windows sends a WM_CLOSE message to the main window.
- The main window object's EvClose member function calls the application object's CanClose member function.
- The application object's CanClose member function calls the main window object's CanClose member function.
- The main window and document manager objects call CanClose for each of their child windows. The main window and document manager objects' CanClose functions return true only if all child windows' CanClose member functions return true.
- If both the main window and document manager objects' CanClose functions return true, the application object's CanClose function returns true.
- If the application object's CanClose function returns true, the EvClose function shuts down the main window and ends the application.