[ui] fix notification sound when closing using X

* Closes #893
This commit is contained in:
Pete Batard 2017-01-30 17:52:37 +00:00
parent e7148c97b5
commit 4373f0c452
2 changed files with 12 additions and 9 deletions

View file

@ -2722,13 +2722,16 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_CLIENTSHUTDOWN:
case WM_QUERYENDSESSION:
case WM_ENDSESSION:
// TODO: Do we want to use ShutdownBlockReasonCreate() in Vista and later to stop
// forced shutdown? See https://msdn.microsoft.com/en-us/library/ms700677.aspx
if (format_op_in_progress) {
// WM_QUERYENDSESSION uses this value to prevent shutdown
return (INT_PTR)TRUE;
}
SendMessage(hDlg, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0);
if (message == WM_CLOSE) {
// We must use PostQuitMessage() on VM_CLOSE, to prevent notification sound...
PostQuitMessage(0);
} else {
// ...but we must simulate Cancel on shutdown requests, else the app freezes.
SendMessage(hDlg, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0);
}
break;
case UM_PROGRESS_INIT: