[ui] fix disabling of Quick Format checkbox

* Closes #1211
* Also fix MBR analysis report displayed each time the user changes boot selection
This commit is contained in:
Pete Batard 2018-10-03 19:14:40 +02:00
parent 204908f8e0
commit 790b188b3d
6 changed files with 30 additions and 28 deletions

View file

@ -635,7 +635,7 @@ const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = {
}; };
// Returns TRUE if the drive seems bootable, FALSE otherwise // 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"; const char* mbr_name = "Master Boot Record";
FAKE_FD fake_fd = { 0 }; FAKE_FD fake_fd = { 0 };
@ -646,17 +646,17 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName)
set_bytes_per_sector(SelectedDrive.SectorSize); set_bytes_per_sector(SelectedDrive.SectorSize);
if (!is_br(fp)) { 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; return FALSE;
} }
for (i=0; i<ARRAYSIZE(known_mbr); i++) { for (i=0; i<ARRAYSIZE(known_mbr); i++) {
if (known_mbr[i].fn(fp)) { if (known_mbr[i].fn(fp)) {
uprintf("%s has a %s %s", TargetName, known_mbr[i].str, mbr_name); suprintf("%s has a %s %s", TargetName, known_mbr[i].str, mbr_name);
return TRUE; return TRUE;
} }
} }
uprintf("%s has an unknown %s", TargetName, mbr_name); suprintf("%s has an unknown %s", TargetName, mbr_name);
return TRUE; return TRUE;
} }
@ -784,7 +784,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
suprintf("Partition type: MBR, NB Partitions: %d", SelectedDrive.nPartitions); suprintf("Partition type: MBR, NB Partitions: %d", SelectedDrive.nPartitions);
SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER); SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER);
suprintf("Disk ID: 0x%08X %s", DriveLayout->Mbr.Signature, SelectedDrive.has_mbr_uefi_marker?"(UEFI target)":""); 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; i<DriveLayout->PartitionCount; i++) { for (i=0; i<DriveLayout->PartitionCount; i++) {
isUefiNtfs = FALSE; isUefiNtfs = FALSE;

View file

@ -116,7 +116,7 @@ char GetUnusedDriveLetter(void);
BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label); BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label);
uint64_t GetDriveSize(DWORD DriveIndex); uint64_t GetDriveSize(DWORD DriveIndex);
BOOL IsMediaPresent(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 AnalyzePBR(HANDLE hLogicalVolume);
BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize, BOOL bSilent); BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize, BOOL bSilent);
BOOL UnmountVolume(HANDLE hDrive); BOOL UnmountVolume(HANDLE hDrive);

View file

@ -890,7 +890,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
FILE* fp = (FILE*)&fake_fd; FILE* fp = (FILE*)&fake_fd;
const char* using_msg = "Using %s MBR\n"; const char* using_msg = "Using %s MBR\n";
AnalyzeMBR(hPhysicalDrive, "Drive"); AnalyzeMBR(hPhysicalDrive, "Drive", FALSE);
if (SelectedDrive.SectorSize < 512) if (SelectedDrive.SectorSize < 512)
goto out; goto out;
@ -1818,7 +1818,7 @@ DWORD WINAPI FormatThread(void* param)
if (!zero_drive && !write_as_image) { if (!zero_drive && !write_as_image) {
PrintInfoDebug(0, MSG_226); PrintInfoDebug(0, MSG_226);
AnalyzeMBR(hPhysicalDrive, "Drive"); AnalyzeMBR(hPhysicalDrive, "Drive", FALSE);
if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) {
AnalyzePBR(hLogicalVolume); AnalyzePBR(hLogicalVolume);
} }

View file

@ -687,18 +687,19 @@ static void EnableQuickFormat(BOOL enable)
// Disable/restore the quick format control depending on large FAT32 or ReFS // 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 (((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) || (fs == FS_REFS)) {
if (IsWindowEnabled(hCtrl)) { enable = FALSE;
}
if (IsWindowEnabled(hCtrl) && !enable) {
uQFChecked = IsChecked(IDC_QUICK_FORMAT); uQFChecked = IsChecked(IDC_QUICK_FORMAT);
CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, BST_CHECKED); CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, BST_CHECKED);
EnableWindow(hCtrl, FALSE); } else if (!IsWindowEnabled(hCtrl) && enable) {
}
} else {
if (!IsWindowEnabled(hCtrl)) {
CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, uQFChecked); CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, uQFChecked);
}
// Now enable or disable the control
EnableWindow(hCtrl, enable); EnableWindow(hCtrl, enable);
} }
}
}
static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes) 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)) if ((HIWORD(wParam) != CBN_SELCHANGE) && (HIWORD(wParam) != CBN_SELCHANGE_INTERNAL))
break; break;
set_selected_fs = (HIWORD(wParam) == CBN_SELCHANGE); 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); SetClusterSizes(fs);
EnableQuickFormat(TRUE);
if (fs < 0) { if (fs < 0) {
EnableBootOptions(TRUE, TRUE); EnableBootOptions(TRUE, TRUE);
SetMBRProps(); SetMBRProps();
@ -2119,8 +2119,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 1)); IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 1));
} }
break; break;
} else if (set_selected_fs) { } else {
EnableQuickFormat(TRUE);
// Try to keep track of user selection // Try to keep track of user selection
if (set_selected_fs)
selected_fs = fs; selected_fs = fs;
} }
EnableMBRBootOptions(TRUE, FALSE); EnableMBRBootOptions(TRUE, FALSE);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.4.1402" CAPTION "Rufus 3.4.1403"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,4,1402,0 FILEVERSION 3,4,1403,0
PRODUCTVERSION 3,4,1402,0 PRODUCTVERSION 3,4,1403,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie" VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.4.1402" VALUE "FileVersion", "3.4.1403"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.4.exe" VALUE "OriginalFilename", "rufus-3.4.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.4.1402" VALUE "ProductVersion", "3.4.1403"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -287,7 +287,7 @@ BOOL IsBootableImage(const char* path)
is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path); is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path);
if (img_report.compression_type == BLED_COMPRESSION_NONE) 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)) { if (!GetFileSizeEx(handle, &liImageSize)) {
uprintf(" Could not get image size: %s", WindowsErrorString()); uprintf(" Could not get image size: %s", WindowsErrorString());