The information in this article applies to:
SUMMARY
In the Microsoft Windows graphical environment, an application can
close in two different ways. The first method involves the user
closing the application, which includes choosing a menu item, double-
clicking the application's system menu, or choosing End Task in the
Windows Task Manager. The second method involves the user ending the
Windows session in the active shell program (either Program Manager or
File Manager).
MORE INFORMATIONMethod 1The three sets of actions below are facets of the first method above:
If the application is to close, it must call the DestroyWindow function to destroy the main window. If the user is not ready to close the application, the application must not pass the WM_CLOSE to DefWindowProc because it will call DestroyWindow. DestroyWindow recursively destroys all child windows of the main window and all windows owned by the main window. If the application has created windows that are neither children of nor owned by the main window, the application must explicitly destroy these windows. Method 2In the second method listed above, when the user ends the Windows session from the active shell program (Program Manager or File Manager), Windows sends a WM_QUERYENDSESSION message to all tasks in the system. An application can process this message to determine when the user terminates the Windows session. When an application receives a WM_QUERYENDSESSION message, if files have been changed and the changes have not been saved, the application must inform the user and confirm the request to close the application. If the application receives confirmation, it must return TRUE after processing the WM_QUERYENDSESSION message. If the user does not confirm closing the application, it must return FALSE to cancel closing Windows.If any application cancels closing Windows in response to a WM_QUERYENDSESSION message, Windows sends a WM_ENDSESSION message with wParam set to FALSE for all applications. This informs each application that the Windows session will continue. If all applications return TRUE after processing the WM_QUERYENDSESSION message, Windows sends each application a WM_ENDSESSION message with wParam set to TRUE. This informs the application that the current Windows session will end very shortly. After the WM_ENDSESSION message, an application receives neither a WM_CLOSE nor a WM_DESTROY message. In summary, if an application must perform operations before it can exit, such as saving files, the application must be prepared for both the application close and Windows shutdown cases. Additional query words:
Keywords : kb16bitonly kbSDKPlatform kbGrpUser kbWndw |
Last Reviewed: November 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |