From 790b188b3d7394a7ce60f1dc7c2b71373e8bf8b1 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 3 Oct 2018 19:14:40 +0200 Subject: [PATCH] [ui] fix disabling of Quick Format checkbox * Closes #1211 * Also fix MBR analysis report displayed each time the user changes boot selection --- src/drive.c | 10 +++++----- src/drive.h | 2 +- src/format.c | 4 ++-- src/rufus.c | 30 ++++++++++++++++-------------- src/rufus.rc | 10 +++++----- src/vhd.c | 2 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/drive.c b/src/drive.c index a1025a17..5821b02d 100644 --- a/src/drive.c +++ b/src/drive.c @@ -635,7 +635,7 @@ const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = { }; // Returns TRUE if the drive seems bootable, FALSE otherwise -BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName) +BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent) { const char* mbr_name = "Master Boot Record"; FAKE_FD fake_fd = { 0 }; @@ -646,17 +646,17 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName) set_bytes_per_sector(SelectedDrive.SectorSize); if (!is_br(fp)) { - uprintf("%s does not have an x86 %s", TargetName, mbr_name); + suprintf("%s does not have an x86 %s", TargetName, mbr_name); return FALSE; } for (i=0; iMbr.Signature == MBR_UEFI_MARKER); suprintf("Disk ID: 0x%08X %s", DriveLayout->Mbr.Signature, SelectedDrive.has_mbr_uefi_marker?"(UEFI target)":""); - AnalyzeMBR(hPhysical, "Drive"); + AnalyzeMBR(hPhysical, "Drive", bSilent); } for (i=0; iPartitionCount; i++) { isUefiNtfs = FALSE; diff --git a/src/drive.h b/src/drive.h index 806ada39..d1722c55 100644 --- a/src/drive.h +++ b/src/drive.h @@ -116,7 +116,7 @@ char GetUnusedDriveLetter(void); BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label); uint64_t GetDriveSize(DWORD DriveIndex); BOOL IsMediaPresent(DWORD DriveIndex); -BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName); +BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent); BOOL AnalyzePBR(HANDLE hLogicalVolume); BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize, BOOL bSilent); BOOL UnmountVolume(HANDLE hDrive); diff --git a/src/format.c b/src/format.c index daeac7c2..339f076b 100644 --- a/src/format.c +++ b/src/format.c @@ -890,7 +890,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) FILE* fp = (FILE*)&fake_fd; const char* using_msg = "Using %s MBR\n"; - AnalyzeMBR(hPhysicalDrive, "Drive"); + AnalyzeMBR(hPhysicalDrive, "Drive", FALSE); if (SelectedDrive.SectorSize < 512) goto out; @@ -1818,7 +1818,7 @@ DWORD WINAPI FormatThread(void* param) if (!zero_drive && !write_as_image) { PrintInfoDebug(0, MSG_226); - AnalyzeMBR(hPhysicalDrive, "Drive"); + AnalyzeMBR(hPhysicalDrive, "Drive", FALSE); if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { AnalyzePBR(hLogicalVolume); } diff --git a/src/rufus.c b/src/rufus.c index 8aad76e0..9d19a76c 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -687,17 +687,18 @@ static void EnableQuickFormat(BOOL enable) // Disable/restore the quick format control depending on large FAT32 or ReFS if (((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) || (fs == FS_REFS)) { - if (IsWindowEnabled(hCtrl)) { - uQFChecked = IsChecked(IDC_QUICK_FORMAT); - CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, BST_CHECKED); - EnableWindow(hCtrl, FALSE); - } - } else { - if (!IsWindowEnabled(hCtrl)) { - CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, uQFChecked); - EnableWindow(hCtrl, enable); - } + enable = FALSE; } + + if (IsWindowEnabled(hCtrl) && !enable) { + uQFChecked = IsChecked(IDC_QUICK_FORMAT); + CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, BST_CHECKED); + } else if (!IsWindowEnabled(hCtrl) && enable) { + CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, uQFChecked); + } + + // Now enable or disable the control + EnableWindow(hCtrl, enable); } static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes) @@ -2106,9 +2107,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if ((HIWORD(wParam) != CBN_SELCHANGE) && (HIWORD(wParam) != CBN_SELCHANGE_INTERNAL)) break; set_selected_fs = (HIWORD(wParam) == CBN_SELCHANGE); - fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + fs = IsWindowEnabled(hFileSystem) ? (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)) : -1; SetClusterSizes(fs); - EnableQuickFormat(TRUE); if (fs < 0) { EnableBootOptions(TRUE, TRUE); SetMBRProps(); @@ -2119,9 +2119,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 1)); } break; - } else if (set_selected_fs) { + } else { + EnableQuickFormat(TRUE); // Try to keep track of user selection - selected_fs = fs; + if (set_selected_fs) + selected_fs = fs; } EnableMBRBootOptions(TRUE, FALSE); SetMBRProps(); diff --git a/src/rufus.rc b/src/rufus.rc index d1733b8b..ca0f39c7 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.4.1402" +CAPTION "Rufus 3.4.1403" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,4,1402,0 - PRODUCTVERSION 3,4,1402,0 + FILEVERSION 3,4,1403,0 + PRODUCTVERSION 3,4,1403,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.4.1402" + VALUE "FileVersion", "3.4.1403" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.4.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.4.1402" + VALUE "ProductVersion", "3.4.1403" END END BLOCK "VarFileInfo" diff --git a/src/vhd.c b/src/vhd.c index 8a81a9f3..6c335d75 100644 --- a/src/vhd.c +++ b/src/vhd.c @@ -287,7 +287,7 @@ BOOL IsBootableImage(const char* path) is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path); if (img_report.compression_type == BLED_COMPRESSION_NONE) - is_bootable_img = (BOOLEAN)AnalyzeMBR(handle, " Image"); + is_bootable_img = (BOOLEAN)AnalyzeMBR(handle, " Image", FALSE); if (!GetFileSizeEx(handle, &liImageSize)) { uprintf(" Could not get image size: %s", WindowsErrorString());