WM QUIT
This message is posted to terminate the application.
Syntax
param1 ULONG ulReserved param2 ULONG ulReserved
Parameters
- ulReserved (ULONG)
- Reserved value, should be 0.
- ulReserved (ULONG)
- Reserved value, should be 0.
Returns
- ulReserved (ULONG)
- Reserved value, should be 0.
Remarks
It causes WinGetMsg to return as for all other messages.
Note: Applications that call WinPeekMsg rather than WinGetMsg should test explicitly for WM_QUIT.
This message should not be dispatched to the default window procedure. The intent of this message is to cause the WinGetMsg loop to terminate.
Typically this message is posted by the application when the application exit command is selected from the action bar.
This message is also sent to all applications when the system is closing down. To reply to this, the application should either cancel the request by issuing an WinCancelShutdown function or close itself down by issuing a WinDestroyMsgQueue function.
Default Processing
The default window procedure takes no action on this message, other than to set ulReserved to 0.
Example Code
In this example, a WM_CLOSE message is received. If the fChanges flag is set, the application calls a function to determine if the user wants to save the changes before exiting. This function (called QuerySaveFile in this example) asks the user if he wants to save the changes. If the user selects OK, the changes are saved. If the user selects cancel, the function returns this value and the application continues normal execution. Otherwise, it posts a WM_QUIT message to terminate the application.
case WM_CLOSE: if (fChanges) { /* changes have not been saved */ if (QuerySaveFile(hwnd) == MB_CANCEL) { return (0L); /* do not exit after all */ } } WinPostMsg(hwnd, WM_QUIT, 0L, 0L); return (0L);