From 02a5d3e5dbcb0d9d7ac76338ef0120685c68a9e5 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Fri, 31 May 2019 15:46:06 +0200 Subject: [PATCH] UI/updater: Add marquee progress bar for existing file check This can take a while on a hard drive since it hashes the entire OBS installation, show a undetermined progress marquee to avoid users thinking that the updater has frozen. --- UI/win-update/updater/updater.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index afa693a8b..0adc9455c 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -1141,6 +1141,12 @@ static bool Update(wchar_t *cmdLine) SetDlgItemTextW(hwndMain, IDC_STATUS, L"Searching for available updates..."); + HWND hProgress = GetDlgItem(hwndMain, IDC_PROGRESS); + LONG_PTR style = GetWindowLongPtr(hProgress, GWL_STYLE); + SetWindowLongPtr(hProgress, GWL_STYLE, style | PBS_MARQUEE); + + SendDlgItemMessage(hwndMain, IDC_PROGRESS, PBM_SETMARQUEE, 1, 0); + /* ------------------------------------- * * Check if updating portable build */ @@ -1250,6 +1256,9 @@ static bool Update(wchar_t *cmdLine) } } + SendDlgItemMessage(hwndMain, IDC_PROGRESS, PBM_SETMARQUEE, 0, 0); + SetWindowLongPtr(hProgress, GWL_STYLE, style); + /* ------------------------------------- * * Exit if updates already installed */ @@ -1460,8 +1469,10 @@ static DWORD WINAPI UpdateThread(void *arg) if (WaitForSingleObject(cancelRequested, 0) == WAIT_OBJECT_0) Status(L"Update aborted."); - SendDlgItemMessage(hwndMain, IDC_PROGRESS, PBM_SETSTATE, - PBST_ERROR, 0); + HWND hProgress = GetDlgItem(hwndMain, IDC_PROGRESS); + LONG_PTR style = GetWindowLongPtr(hProgress, GWL_STYLE); + SetWindowLongPtr(hProgress, GWL_STYLE, style & ~PBS_MARQUEE); + SendMessage(hProgress, PBM_SETSTATE, PBST_ERROR, 0); SetDlgItemText(hwndMain, IDC_BUTTON, L"Exit"); EnableWindow(GetDlgItem(hwndMain, IDC_BUTTON), true); -- GitLab