msgs12.hlp (Topic list)
WM_CLOSE (1.2)
Changes                                             Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_WINMESSAGEMGR
 
WM_CLOSE
 
The WM_CLOSE message is sent as a signal that the window or its application
should terminate. This message allows the window to control the termination
process.
 
This message does not use any parameters.
 
Return Value
 
An application should return zero if it processes this message.
 
Comments
 
If WM_CLOSE is passed to the WinDefDlgProc function, the function calls the
WinDismissDlg function and passes the DID_CANCEL result code to it.
 
Example
 
In the following example, the fChanges variable is checked. If it is TRUE,
the user is asked if he or she wants to exit without saving any changes. If
the user responds by choosing the No button, then zero is returned and the
application does not exit. If the user responds by choosing the Yes button,
then a WM_QUIT message is posted so that the application will terminate.
 
case WM_CLOSE:
    if (fChanges) {
        if (WinMessageBox(HWND_DESKTOP, hwndClient,
                "Do you want to exit without saving your changes?",
                "", 0, MB_NOICON | MB_YESNO) == MBID_NO)
            return (0L);
    }
    WinPostMsg(hwnd, WM_QUIT, 0L, 0L);
    return (0L);
 
See Also
 
WinDefWindowProc, WinMessageBox, WinPostMsg, WM_QUIT