From cdacc6f342f8ac66dce005041556a0162a05398f Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 8 May 2018 20:28:23 +0100 Subject: [PATCH] [ui] fix whole screen refresh and progress bar issues * Whole screen was being refreshed when calling InvalidateRect() in ResizeMoveCtrl() * Progress bar bounding rectangle could be erased at 0.0% * No progress was displayed when writing ISOHybrid images in DD mode * Also fix an issue when write error would not display the error string --- src/format.c | 6 +++--- src/rufus.c | 12 +++++++----- src/rufus.rc | 10 +++++----- src/stdlg.c | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/format.c b/src/format.c index 00c1d05c..d1ce5af1 100644 --- a/src/format.c +++ b/src/format.c @@ -1601,7 +1601,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) if (s) uprintf("write error: Wrote %d bytes, expected %d bytes", wSize, rSize); else - uprintf("write error at sector %d: %s", wb / SelectedDrive.SectorSize, WindowsErrorString()); + uprintf("write error at sector %" PRIi64 ": %s", wb / SelectedDrive.SectorSize, WindowsErrorString()); if (i < WRITE_RETRIES - 1) { li.QuadPart = wb; uprintf(" RETRYING...\n"); @@ -1728,7 +1728,7 @@ DWORD WINAPI FormatThread(void* param) } CHECK_FOR_USER_CANCEL; - if (!zero_drive) { + if (!zero_drive && !write_as_image) { PrintInfoDebug(0, MSG_226); AnalyzeMBR(hPhysicalDrive, "Drive"); if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { @@ -1746,7 +1746,7 @@ DWORD WINAPI FormatThread(void* param) // Note, Microsoft's way of cleaning partitions (IOCTL_DISK_CREATE_DISK, which is what we apply // in InitializeDisk) is *NOT ENOUGH* to reset a disk and can render it inoperable for partitioning // or formatting under Windows. See https://github.com/pbatard/rufus/issues/759 for details. - if ((bt != BT_IMAGE) || (img_report.is_iso)) { + if ((bt != BT_IMAGE) || (img_report.is_iso && !write_as_image)) { if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) || (!InitializeDisk(hPhysicalDrive))) { uprintf("Could not reset partitions\n"); diff --git a/src/rufus.c b/src/rufus.c index 4a3786b2..4eed404b 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -1775,7 +1775,7 @@ static __inline const char* IsAlphaOrBeta(void) static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam, LPARAM lParam) { HDC hDC; - RECT rc; + RECT rc, rc2; PAINTSTRUCT ps; SIZE size; LONG full_right; @@ -1840,11 +1840,10 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam case WM_PAINT: hDC = BeginPaint(hCtrl, &ps); GetClientRect(hCtrl, &rc); + rc2 = rc; + InflateRect(&rc, -1, -1); SelectObject(hDC, GetStockObject(DC_PEN)); SelectObject(hDC, GetStockObject(NULL_BRUSH)); - SetDCPenColor(hDC, PROGRESS_BAR_BOX_COLOR); - Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); - InflateRect(&rc, -1, -1); // TODO: Handle SetText message so we can avoid this call GetWindowTextW(hProgress, winfo, ARRAYSIZE(winfo)); SelectObject(hDC, hInfoFont); @@ -1901,6 +1900,9 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0), &rc, winfo, (int)wcslen(winfo), NULL); + // Bounding rectangle + SetDCPenColor(hDC, PROGRESS_BAR_BOX_COLOR); + Rectangle(hDC, rc2.left, rc2.top, rc2.right, rc2.bottom); EndPaint(hCtrl, &ps); return (INT_PTR)TRUE; } @@ -3285,7 +3287,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA goto aborted_start; DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex); - InitProgress(zero_drive); + InitProgress(zero_drive || write_as_image); format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL); if (format_thid == NULL) { uprintf("Unable to start formatting thread"); diff --git a/src/rufus.rc b/src/rufus.rc index 48759b9e..a5675300 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.0.1268" +CAPTION "Rufus 3.0.1269" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -389,8 +389,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,0,1268,0 - PRODUCTVERSION 3,0,1268,0 + FILEVERSION 3,0,1269,0 + PRODUCTVERSION 3,0,1269,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -407,13 +407,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.0.1268" + VALUE "FileVersion", "3.0.1269" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.0.1268" + VALUE "ProductVersion", "3.0.1269" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 37c276d4..df26c6b5 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -485,7 +485,7 @@ void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int dx, int dy, int dw, int dh, float MoveWindow(hCtrl, point.x + (int)(scale*(float)dx), point.y + (int)(scale*(float)dy), (rect.right - rect.left) + (int)(scale*(float)dw + border.cx), (rect.bottom - rect.top) + (int)(scale*(float)dh + border.cy), TRUE); - InvalidateRect(hCtrl, NULL, TRUE); + // Don't be tempted to call InvalidateRect() here - it causes intempestive whole screen refreshes } void ResizeButtonHeight(HWND hDlg, int id)