[SETUP:REACTOS] Collect some UI elements into a common UI_CONTEXT structure.

Handles to some install-page UI elements, used in the installation thread,
are collected into a UI_CONTEXT structure.
This commit is contained in:
Hermès Bélusca-Maïto 2024-02-20 20:55:59 +01:00
parent 58cad127dc
commit 9b2b75df2b
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 40 additions and 32 deletions

View file

@ -41,6 +41,9 @@ HANDLE ProcessHeap;
BOOLEAN IsUnattendedSetup = FALSE;
SETUPDATA SetupData;
/* UI elements */
UI_CONTEXT UiContext;
/* FUNCTIONS ****************************************************************/
@ -1104,8 +1107,6 @@ SummaryDlgProc(
typedef struct _COPYCONTEXT
{
PSETUPDATA pSetupData;
HWND hWndItem;
HWND hWndProgress;
ULONG TotalOperations;
ULONG CompletedOperations;
} COPYCONTEXT, *PCOPYCONTEXT;
@ -1133,10 +1134,10 @@ FileCopyCallback(PVOID Context,
CopyContext->TotalOperations = (ULONG)Param2;
CopyContext->CompletedOperations = 0;
SendMessageW(CopyContext->hWndProgress,
SendMessageW(UiContext.hWndProgress,
PBM_SETRANGE, 0,
MAKELPARAM(0, CopyContext->TotalOperations));
SendMessageW(CopyContext->hWndProgress,
SendMessageW(UiContext.hWndProgress,
PBM_SETSTEP, 1, 0);
break;
}
@ -1158,7 +1159,7 @@ FileCopyCallback(PVOID Context,
// STRING_DELETING
StringCchPrintfW(Status, ARRAYSIZE(Status), L"Deleting %s", DstFileName);
SetWindowTextW(CopyContext->hWndItem, Status);
SetWindowTextW(UiContext.hWndItem, Status);
}
else if (Notification == SPFILENOTIFY_STARTRENAME)
{
@ -1179,7 +1180,7 @@ FileCopyCallback(PVOID Context,
else
StringCchPrintfW(Status, ARRAYSIZE(Status), L"Renaming %s to %s", SrcFileName, DstFileName);
SetWindowTextW(CopyContext->hWndItem, Status);
SetWindowTextW(UiContext.hWndItem, Status);
}
else if (Notification == SPFILENOTIFY_STARTCOPY)
{
@ -1192,7 +1193,7 @@ FileCopyCallback(PVOID Context,
// STRING_COPYING
StringCchPrintfW(Status, ARRAYSIZE(Status), L"Copying %s", DstFileName);
SetWindowTextW(CopyContext->hWndItem, Status);
SetWindowTextW(UiContext.hWndItem, Status);
}
break;
}
@ -1207,7 +1208,7 @@ FileCopyCallback(PVOID Context,
if (CopyContext->TotalOperations >> 1 == CopyContext->CompletedOperations)
DPRINT1("CHECKPOINT:HALF_COPIED\n");
SendMessageW(CopyContext->hWndProgress, PBM_STEPIT, 0, 0);
SendMessageW(UiContext.hWndProgress, PBM_STEPIT, 0, 0);
break;
}
}
@ -1234,6 +1235,12 @@ PrepareAndDoCopyThread(
/* Get the progress handle */
hWndProgress = GetDlgItem(hwndDlg, IDC_PROCESSPROGRESS);
/* Setup global UI context */
UiContext.hwndDlg = hwndDlg;
UiContext.hWndItem = GetDlgItem(hwndDlg, IDC_ITEM);
UiContext.hWndProgress = hWndProgress;
UiContext.dwPbStyle = 0;
/*
* Preparation of the list of files to be copied
@ -1243,27 +1250,24 @@ PrepareAndDoCopyThread(
SetDlgItemTextW(hwndDlg, IDC_ACTIVITY, L"Preparing the list of files to be copied, please wait...");
SetDlgItemTextW(hwndDlg, IDC_ITEM, L"");
/* Set progress marquee style */
/* Set progress marquee style and start it up */
dwStyle = GetWindowLongPtrW(hWndProgress, GWL_STYLE);
SetWindowLongPtrW(hWndProgress, GWL_STYLE, dwStyle | PBS_MARQUEE);
/* Start it up */
SendMessageW(hWndProgress, PBM_SETMARQUEE, TRUE, 0);
/* Prepare the list of files */
/* ErrorNumber = */ Success = PrepareFileCopy(&pSetupData->USetupData, NULL);
/* Stop progress and restore its style */
SendMessageW(hWndProgress, PBM_SETMARQUEE, FALSE, 0);
SetWindowLongPtrW(hWndProgress, GWL_STYLE, dwStyle);
if (/*ErrorNumber != ERROR_SUCCESS*/ !Success)
{
/* Display an error only if an unexpected failure happened, and not because the user cancelled the installation */
if (!pSetupData->bStopInstall)
MessageBoxW(GetParent(hwndDlg), L"Failed to prepare the list of files!", L"Error", MB_ICONERROR);
/* Stop it */
SendMessageW(hWndProgress, PBM_SETMARQUEE, FALSE, 0);
/* Restore progress style */
SetWindowLongPtrW(hWndProgress, GWL_STYLE, dwStyle);
/*
* If we failed due to an unexpected error, keep on the copy page to view the current state,
* but enable the "Next" button to allow the user to continue to the terminate page.
@ -1274,12 +1278,6 @@ PrepareAndDoCopyThread(
return 1;
}
/* Stop it */
SendMessageW(hWndProgress, PBM_SETMARQUEE, FALSE, 0);
/* Restore progress style */
SetWindowLongPtrW(hWndProgress, GWL_STYLE, dwStyle);
/*
* Perform the file copy
@ -1291,8 +1289,6 @@ PrepareAndDoCopyThread(
/* Create context for the copy process */
CopyContext.pSetupData = pSetupData;
CopyContext.hWndItem = GetDlgItem(hwndDlg, IDC_ITEM);
CopyContext.hWndProgress = hWndProgress;
CopyContext.TotalOperations = 0;
CopyContext.CompletedOperations = 0;

View file

@ -69,14 +69,17 @@
// #include <reactos/rosioctl.h>
#include <../lib/setuplib.h>
#if 0
typedef struct _KBLAYOUT
/* UI elements */
typedef struct _UI_CONTEXT
{
TCHAR LayoutId[9];
TCHAR LayoutName[128];
TCHAR DllName[128];
} KBLAYOUT, *PKBLAYOUT;
#endif
HWND hwndDlg; // Install progress page
HWND hWndItem; // Progress action
HWND hWndProgress; // Progress gauge
LONG_PTR dwPbStyle; // Progress gauge style
} UI_CONTEXT, *PUI_CONTEXT;
extern UI_CONTEXT UiContext;
/*
@ -108,6 +111,15 @@ typedef struct _NT_WIN32_PATH_MAPPING_LIST
} NT_WIN32_PATH_MAPPING_LIST, *PNT_WIN32_PATH_MAPPING_LIST;
#if 0
typedef struct _KBLAYOUT
{
TCHAR LayoutId[9];
TCHAR LayoutName[128];
TCHAR DllName[128];
} KBLAYOUT, *PKBLAYOUT;
#endif
typedef struct _SETUPDATA
{
/* General */