From 53aabf3f14e75762759bf58fbe726934db38ef76 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Thu, 5 May 2016 13:12:25 +0200 Subject: Windows: Add option and command line switch to hide waiting dialog when performing operations. --- src/Common/Dlgcode.c | 40 +++++++++++++++++++++++++++++++++------- src/Common/Dlgcode.h | 3 +++ src/Common/Language.xml | 1 + src/ExpandVolume/WinMain.cpp | 2 ++ src/Format/Tcformat.c | 2 ++ src/Mount/Mount.c | 30 ++++++++++++++++++++++++++++++ src/Mount/Mount.rc | 26 ++++++++++++++------------ src/Mount/Resource.h | 3 ++- 8 files changed, 87 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 6958afe9..97dd5247 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -104,6 +104,9 @@ wchar_t *lpszTitle = NULL; BOOL Silent = FALSE; BOOL bPreserveTimestamp = TRUE; BOOL bShowDisconnectedNetworkDrives = FALSE; +BOOL bHideWaitingDialog = FALSE; +BOOL bCmdHideWaitingDialog = FALSE; +BOOL bCmdHideWaitingDialogValid = FALSE; BOOL bStartOnLogon = FALSE; BOOL bMountDevicesOnLogon = FALSE; BOOL bMountFavoritesOnLogon = FALSE; @@ -1686,14 +1689,21 @@ SplashDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return DefDlgProcW (hwnd, uMsg, wParam, lParam); } +static int g_waitCursorCounter = 0; + void WaitCursor () { static HCURSOR hcWait; if (hcWait == NULL) hcWait = LoadCursor (NULL, IDC_WAIT); - SetCursor (hcWait); - hCursor = hcWait; + + if ((g_waitCursorCounter == 0) || (hCursor != hcWait)) + { + SetCursor (hcWait); + hCursor = hcWait; + } + g_waitCursorCounter++; } void @@ -1702,8 +1712,13 @@ NormalCursor () static HCURSOR hcArrow; if (hcArrow == NULL) hcArrow = LoadCursor (NULL, IDC_ARROW); - SetCursor (hcArrow); - hCursor = NULL; + if (g_waitCursorCounter > 0) + g_waitCursorCounter--; + if (g_waitCursorCounter == 0) + { + SetCursor (hcArrow); + hCursor = NULL; + } } void @@ -1712,8 +1727,12 @@ ArrowWaitCursor () static HCURSOR hcArrowWait; if (hcArrowWait == NULL) hcArrowWait = LoadCursor (NULL, IDC_APPSTARTING); - SetCursor (hcArrowWait); - hCursor = hcArrowWait; + if ((g_waitCursorCounter == 0) || (hCursor != hcArrowWait)) + { + SetCursor (hcArrowWait); + hCursor = hcArrowWait; + } + g_waitCursorCounter++; } void HandCursor () @@ -5399,8 +5418,12 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP threadParam.hBenchDlg = hwndDlg; threadParam.bStatus = FALSE; + WaitCursor (); + ShowWaitDialog (hwndDlg, TRUE, BenchmarkThreadProc, &threadParam); + NormalCursor (); + if (threadParam.bStatus == FALSE) { EndDialog (hwndDlg, IDCLOSE); @@ -7092,13 +7115,16 @@ void BringToForeground(HWND hWnd) void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, void* pArg) { HWND hParent = (hwnd && bUseHwndAsParent)? hwnd : GetDesktopWindow(); + BOOL bEffectiveHideWaitingDialog = bCmdHideWaitingDialogValid? bCmdHideWaitingDialog : bHideWaitingDialog; WaitThreadParam threadParam; threadParam.callback = callback; threadParam.pArg = pArg; - if (WaitDialogDisplaying) + if (WaitDialogDisplaying || bEffectiveHideWaitingDialog) { + if (!WaitDialogDisplaying) WaitCursor (); callback (pArg, hwnd); + if (!WaitDialogDisplaying) NormalCursor (); } else { diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index d9f29cd0..cf9239e0 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -117,6 +117,9 @@ extern BOOL Silent; extern BOOL bHistory; extern BOOL bPreserveTimestamp; extern BOOL bShowDisconnectedNetworkDrives; +extern BOOL bHideWaitingDialog; +extern BOOL bCmdHideWaitingDialog; +extern BOOL bCmdHideWaitingDialogValid; extern BOOL bStartOnLogon; extern BOOL bMountDevicesOnLogon; extern BOOL bMountFavoritesOnLogon; diff --git a/src/Common/Language.xml b/src/Common/Language.xml index b64e8568..add35c7a 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1398,6 +1398,7 @@ WARNING: Please keep in mind that if you enable this option, the PIM value will be stored unencrypted on the disk.\n\nAre you sure you want to enable this option? Personal Iterations Multiplier (PIM) maximum value is 2147468. Skip Rescue Disk verification + Don't show wait message dialog when performing operations diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp index e6efd1db..fb9d52af 100644 --- a/src/ExpandVolume/WinMain.cpp +++ b/src/ExpandVolume/WinMain.cpp @@ -283,6 +283,7 @@ void LoadSettings (HWND hwndDlg) bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = ConfigReadInt ("PreserveTimestamps", TRUE); bShowDisconnectedNetworkDrives = ConfigReadInt ("ShowDisconnectedNetworkDrives", FALSE); + bHideWaitingDialog = ConfigReadInt ("HideWaitingDialog", FALSE); defaultMountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE); defaultMountOptions.ReadOnly = ConfigReadInt ("MountVolumesReadOnly", FALSE); defaultMountOptions.ProtectHiddenVolume = FALSE; @@ -873,6 +874,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // Set critical default options in case UsePreferences is false bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = TRUE; bShowDisconnectedNetworkDrives = FALSE; + bHideWaitingDialog = FALSE; if (UsePreferences) { diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 4a002084..a4372533 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -766,6 +766,8 @@ static void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, ConfigReadCompareInt ("ShowDisconnectedNetworkDrives", FALSE, &bShowDisconnectedNetworkDrives, bOnlyCheckModified, pbSettingsModified); + ConfigReadCompareInt ("HideWaitingDialog", FALSE, &bHideWaitingDialog, bOnlyCheckModified, pbSettingsModified); + ConfigReadCompareInt ("SaveVolumeHistory", FALSE, &bHistory, bOnlyCheckModified, pbSettingsModified); { diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 7dabc5ff..5bcaddad 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -709,6 +709,8 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* ConfigReadCompareInt ("ShowDisconnectedNetworkDrives", FALSE, &bShowDisconnectedNetworkDrives, bOnlyCheckModified, pbSettingsModified); + ConfigReadCompareInt ("HideWaitingDialog", FALSE, &bHideWaitingDialog, bOnlyCheckModified, pbSettingsModified); + ConfigReadCompareInt ("MountVolumesRemovable", FALSE, &defaultMountOptions.Removable, bOnlyCheckModified, pbSettingsModified); ConfigReadCompareInt ("MountVolumesReadOnly", FALSE, &defaultMountOptions.ReadOnly, bOnlyCheckModified, pbSettingsModified); @@ -865,6 +867,7 @@ void SaveSettings (HWND hwndDlg) ConfigWriteInt ("MountVolumesRemovable", defaultMountOptions.Removable); ConfigWriteInt ("PreserveTimestamps", defaultMountOptions.PreserveTimestamp); ConfigWriteInt ("ShowDisconnectedNetworkDrives",bShowDisconnectedNetworkDrives); + ConfigWriteInt ("HideWaitingDialog", bHideWaitingDialog); ConfigWriteInt ("EnableBackgroundTask", bEnableBkgTask); ConfigWriteInt ("CloseBackgroundTaskOnNoVolumes", bCloseBkgTaskWhenNoVolumes); @@ -3104,6 +3107,9 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendMessage (GetDlgItem (hwndDlg, IDC_SHOW_DISCONNECTED_NETWORK_DRIVES), BM_SETCHECK, bShowDisconnectedNetworkDrives ? BST_CHECKED:BST_UNCHECKED, 0); + + SendMessage (GetDlgItem (hwndDlg, IDC_HIDE_WAITING_DIALOG), BM_SETCHECK, + bHideWaitingDialog ? BST_CHECKED:BST_UNCHECKED, 0); SendMessage (GetDlgItem (hwndDlg, IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT), BM_SETCHECK, bCacheDuringMultipleMount ? BST_CHECKED:BST_UNCHECKED, 0); @@ -3219,6 +3225,7 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM bUseDifferentTrayIconIfVolMounted = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED)); bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS)); bShowDisconnectedNetworkDrives = IsButtonChecked (GetDlgItem (hwndDlg, IDC_SHOW_DISCONNECTED_NETWORK_DRIVES)); + bHideWaitingDialog = IsButtonChecked (GetDlgItem (hwndDlg, IDC_HIDE_WAITING_DIALOG)); bCacheDuringMultipleMount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT)); bWipeCacheOnExit = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_EXIT)); bWipeCacheOnAutoDismount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT)); @@ -6371,6 +6378,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // Set critical default options in case UsePreferences is false bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = TRUE; bShowDisconnectedNetworkDrives = FALSE; + bHideWaitingDialog = FALSE; ResetWrongPwdRetryCount (); @@ -8353,6 +8361,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) OptionTrueCryptMode, OptionPim, OptionTryEmptyPassword, + OptionNoWaitDlg, }; argument args[]= @@ -8379,6 +8388,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) { OptionVolume, L"/volume", L"/v", FALSE }, { CommandWipeCache, L"/wipecache", L"/w", FALSE }, { OptionTryEmptyPassword, L"/tryemptypass", NULL, FALSE }, + { OptionNoWaitDlg, L"/nowaitdlg", NULL, FALSE }, }; argumentspec as; @@ -8431,6 +8441,25 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) } break; + case OptionNoWaitDlg: + { + wchar_t szTmp[16] = {0}; + bCmdHideWaitingDialog = TRUE; + bCmdHideWaitingDialogValid = TRUE; + + if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, + szTmp, ARRAYSIZE (szTmp))) + { + if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no")) + bCmdHideWaitingDialog = FALSE; + else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes")) + bCmdHideWaitingDialog = TRUE; + else + AbortProcess ("COMMAND_LINE_ERROR"); + } + } + break; + case OptionCache: { wchar_t szTmp[16] = {0}; @@ -8855,6 +8884,7 @@ static BOOL StartSystemFavoritesService () Silent = TRUE; DeviceChangeBroadcastDisabled = TRUE; bShowDisconnectedNetworkDrives = TRUE; + bHideWaitingDialog = TRUE; InitOSVersionInfo(); diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc index 96bb95c4..4aad9360 100644 --- a/src/Mount/Mount.rc +++ b/src/Mount/Mount.rc @@ -41,7 +41,7 @@ IDR_MOUNT_TLB TYPELIB "Mount.tlb" // Dialog // -IDD_PREFERENCES_DLG DIALOGEX 0, 0, 336, 316 +IDD_PREFERENCES_DLG DIALOGEX 0, 0, 336, 333 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Preferences" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -78,26 +78,28 @@ BEGIN CONTROL "Make disconnected network drives available for mounting",IDC_SHOW_DISCONNECTED_NETWORK_DRIVES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,208,316,10 CONTROL "Cache passwords in driver memory",IDC_PREF_CACHE_PASSWORDS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,238,146,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,254,146,11 CONTROL "Wipe cached passwords on exit",IDC_PREF_WIPE_CACHE_ON_EXIT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,238,165,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,254,165,11 CONTROL "Temporary Cache password during ""Mount Favorite Volumes"" operations",IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,252,294,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,268,294,11 CONTROL "Wipe cached passwords on auto-dismount",IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,266,296,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,282,296,11 CONTROL "Include PIM when caching a password",IDC_PREF_CACHE_PIM, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,280,296,10 - PUSHBUTTON "More Settings...",IDC_MORE_SETTINGS,5,300,85,14 - DEFPUSHBUTTON "OK",IDOK,225,300,50,14 - PUSHBUTTON "Cancel",IDCANCEL,281,300,50,14 - GROUPBOX "Windows",IDT_WINDOWS_RELATED_SETTING,4,160,328,62 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,296,296,10 + PUSHBUTTON "More Settings...",IDC_MORE_SETTINGS,5,317,85,14 + DEFPUSHBUTTON "OK",IDOK,225,317,50,14 + PUSHBUTTON "Cancel",IDCANCEL,281,317,50,14 + GROUPBOX "Windows",IDT_WINDOWS_RELATED_SETTING,4,160,328,76 GROUPBOX "Default Mount Options",IDT_DEFAULT_MOUNT_OPTIONS,4,3,328,26 GROUPBOX "VeraCrypt Background Task",IDT_TASKBAR_ICON,4,33,328,26 GROUPBOX "Auto-Dismount",IDT_AUTO_DISMOUNT,4,94,328,62 LTEXT "minutes",IDT_MINUTES,289,129,39,10 LTEXT "Dismount all when:",IDT_AUTO_DISMOUNT_ON,9,104,71,20 - GROUPBOX "Password Cache",IDT_PW_CACHE_OPTIONS,4,227,328,68 + GROUPBOX "Password Cache",IDT_PW_CACHE_OPTIONS,4,243,328,68 GROUPBOX "Actions to perform upon logon to Windows",IDT_LOGON,4,63,328,28 + CONTROL "Don't show wait message dialog when performing operations",IDC_HIDE_WAITING_DIALOG, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,220,316,10 END IDD_VOLUME_PROPERTIES DIALOGEX 60, 30, 284, 224 @@ -398,7 +400,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 329 TOPMARGIN, 7 - BOTTOMMARGIN, 314 + BOTTOMMARGIN, 331 END IDD_VOLUME_PROPERTIES, DIALOG diff --git a/src/Mount/Resource.h b/src/Mount/Resource.h index c5a45af4..210cfde2 100644 --- a/src/Mount/Resource.h +++ b/src/Mount/Resource.h @@ -180,6 +180,7 @@ #define IDC_FAVORITE_VOLUME_ID 1158 #define IDC_FAVORITE_USE_VOLUME_ID 1159 #define IDC_DISABLE_BOOT_LOADER_PIM_PROMPT 1160 +#define IDC_HIDE_WAITING_DIALOG 1161 #define IDM_HELP 40001 #define IDM_ABOUT 40002 #define IDM_UNMOUNT_VOLUME 40003 @@ -256,7 +257,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 119 #define _APS_NEXT_COMMAND_VALUE 40069 -#define _APS_NEXT_CONTROL_VALUE 1161 +#define _APS_NEXT_CONTROL_VALUE 1162 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif -- cgit v1.2.3