Windows: Implement waiting dialog for Auto-Mount Devices operations to avoid freezing GUI.

This commit is contained in:
Mounir IDRASSI 2015-06-10 00:58:50 +02:00
parent b7eadfd310
commit 6be12f4889

View File

@ -4415,9 +4415,9 @@ static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dis
return status; return status;
} }
static BOOL MountAllDevices (HWND hwndDlg, BOOL bPasswordPrompt) static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
{ {
HWND driveList = GetDlgItem (hwndDlg, IDC_DRIVELIST); HWND driveList = GetDlgItem (MainDlg, IDC_DRIVELIST);
int selDrive = ListView_GetSelectionMark (driveList); int selDrive = ListView_GetSelectionMark (driveList);
BOOL shared = FALSE, status = FALSE, bHeaderBakRetry = FALSE; BOOL shared = FALSE, status = FALSE, bHeaderBakRetry = FALSE;
int mountedVolCount = 0; int mountedVolCount = 0;
@ -4536,7 +4536,7 @@ static BOOL MountAllDevices (HWND hwndDlg, BOOL bPasswordPrompt)
if (mounted == 2) if (mounted == 2)
shared = TRUE; shared = TRUE;
LoadDriveLetters (hwndDlg, driveList, (HIWORD (GetItemLong (GetDlgItem (hwndDlg, IDC_DRIVELIST), selDrive)))); LoadDriveLetters (hwndDlg, driveList, (HIWORD (GetItemLong (GetDlgItem (MainDlg, IDC_DRIVELIST), selDrive))));
selDrive++; selDrive++;
if (bExplore) if (bExplore)
@ -4656,13 +4656,38 @@ static BOOL MountAllDevices (HWND hwndDlg, BOOL bPasswordPrompt)
if (UsePreferences) if (UsePreferences)
bCacheInDriver = bCacheInDriverDefault; bCacheInDriver = bCacheInDriverDefault;
EnableDisableButtons (hwndDlg); EnableDisableButtons (MainDlg);
NormalCursor(); NormalCursor();
return status; return status;
} }
typedef struct
{
BOOL bPasswordPrompt;
BOOL bRet;
} MountAllDevicesThreadParam;
void CALLBACK mountAllDevicesThreadProc(void* pArg, HWND hwndDlg)
{
MountAllDevicesThreadParam* threadParam =(MountAllDevicesThreadParam*) pArg;
BOOL bPasswordPrompt = threadParam->bPasswordPrompt;
threadParam->bRet = MountAllDevicesThreadCode (hwndDlg, bPasswordPrompt);
}
static BOOL MountAllDevices (HWND hwndDlg, BOOL bPasswordPrompt)
{
MountAllDevicesThreadParam param;
param.bPasswordPrompt = bPasswordPrompt;
param.bRet = FALSE;
ShowWaitDialog (hwndDlg, TRUE, mountAllDevicesThreadProc, &param);
return param.bRet;
}
static void ChangePassword (HWND hwndDlg) static void ChangePassword (HWND hwndDlg)
{ {
INT_PTR result; INT_PTR result;