From 447464286315da833adecf4982292e71baf759ab Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 2 Feb 2016 16:14:22 +0000 Subject: [PATCH] [ui] fix shutdown prevention issues * Also minor UI improvements for High DPI * Part of issue #676 --- src/rufus.c | 23 ++++++++++++++++++----- src/rufus.rc | 10 +++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/rufus.c b/src/rufus.c index 670d4614..0ff2aa89 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -75,6 +75,9 @@ #ifndef MSGFLT_ADD #define MSGFLT_ADD 1 #endif +#ifndef WM_CLIENTSHUTDOWN +#define WM_CLIENTSHUTDOWN 0x3B +#endif #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x49 #endif @@ -1862,9 +1865,8 @@ void InitDialog(HWND hDlg) rcSelectImage.right - rcSelectImage.left, rcBootType.bottom - rcBootType.top + 2, SWP_NOZORDER); // The things one needs to do to keep things looking good... - if (nWindowsVersion == WINDOWS_7) { - ResizeMoveCtrl(hDlg, GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), 0, -1, 0, 2, fScale); - ResizeMoveCtrl(hDlg, hProgress, 0, 1, 0, 0, fScale); + if (fScale > 1.4f) { + ResizeMoveCtrl(hDlg, GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), 0, +1, 0, 0, fScale); } // Subclass the Info box so that we can align its text vertically @@ -2641,12 +2643,23 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } break; + // This is >>>SUPER WEIRD<<<. After a successful ISO or DD write (e.g. Arch 2016.01) + // we no longer receive WM_QUERYENDSESSION messages, only WM_ENDSESSION. + // But if we do a FreeDOS format, WM_QUERYENDSESSION is still sent to us alright. + // What the heck is going on here?!? + // Also, even as we try to work around this, WM_ENDSESSION comes too late in the game + // to prevent shutdown block. So we need to handle the _undocumented_ WM_CLIENTSHUTDOWN. case WM_CLOSE: + case WM_CLIENTSHUTDOWN: + case WM_QUERYENDSESSION: case WM_ENDSESSION: - if (format_thid != NULL) { + // 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; } - PostQuitMessage(0); + SendMessage(hDlg, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0); break; case UM_PROGRESS_INIT: diff --git a/src/rufus.rc b/src/rufus.rc index aac66e26..8b7afbc2 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.7.840" +CAPTION "Rufus 2.7.841" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -320,8 +320,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,7,840,0 - PRODUCTVERSION 2,7,840,0 + FILEVERSION 2,7,841,0 + PRODUCTVERSION 2,7,841,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -338,13 +338,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.7.840" + VALUE "FileVersion", "2.7.841" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.7.840" + VALUE "ProductVersion", "2.7.841" END END BLOCK "VarFileInfo"