In this example, the fChanges variable is checked. If it is TRUE, the user is asked if he wants to exit without saving any changes. If the user responds by choosing the No button, zero is returned and the application does not exit. If the user responds by choosing the Yes button, a WM_QUIT message is posted and the application terminates.

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);


[Back] [Next]