WM_CLOSE
wParam = 0; /* not used, must be zero */
lParam = 0L; /* not used, must be zero */
The WM_CLOSE message is sent as a signal that a window or an application should terminate. An application can prompt the user for confirmation prior to destroying the window by processing the WM_CLOSE message and calling the DestroyWindow function only if the user confirms the choice.
This message has no parameters.
An application should return zero if it processes this message.
This example processes a WM_CLOSE message and requests confirmation from the user before terminating the application:
case WM_CLOSE:
if (MessageBox(hwnd, "Are you sure you want to exit?", "MyApp",
MB_ICONQUESTION | MB_OKCANCEL) == IDOK)
DestroyWindow(hwnd);
return 0L;