diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Common/Dlgcode.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index eed087aa..56938518 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -7618,5 +7618,10 @@ void BringToForeground(HWND hWnd) +static LRESULT CALLBACK ShowWaitDialogParentWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + return DefWindowProcW (hWnd, message, wParam, lParam); +} + + void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, void* pArg) { - HWND hParent = (hwnd && bUseHwndAsParent)? hwnd : GetDesktopWindow(); BOOL bEffectiveHideWaitingDialog = bCmdHideWaitingDialogValid? bCmdHideWaitingDialog : bHideWaitingDialog; @@ -7634,2 +7639,3 @@ void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, v { + const wchar_t *className = L"VeraCryptShowWaitDialogParent"; BOOL bIsForeground = FALSE; @@ -7637,2 +7643,4 @@ void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, v WaitDialogDisplaying = TRUE; + HWND hParent = NULL; + if (creatorWnd) @@ -7644,2 +7652,24 @@ void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, v + if (hwnd && bUseHwndAsParent) + hParent = hwnd; + else + { + /* create invisible window and use it as parent */ + WNDCLASSEXW winClass; + + memset (&winClass, 0, sizeof (winClass)); + winClass.cbSize = sizeof (WNDCLASSEX); + winClass.lpfnWndProc = (WNDPROC) ShowWaitDialogParentWndProc; + winClass.hInstance = hInst; + winClass.lpszClassName = className; + RegisterClassExW (&winClass); + + hParent = CreateWindowExW (WS_EX_TOOLWINDOW | WS_EX_LAYERED, className, L"VeraCrypt ShowWaitDialog Parent", 0, 0, 0, 1, 1, NULL, NULL, hInst, NULL); + if (hParent) + { + SetLayeredWindowAttributes (hParent, 0, 1, LWA_ALPHA); + ShowWindow (hParent, SW_SHOWNORMAL); + } + } + finally_do_arg2 (HWND, creatorWnd, BOOL, bIsForeground, { if (finally_arg) { EnableWindow(finally_arg, TRUE); if (finally_arg2) BringToForeground (finally_arg);}}); @@ -7651,2 +7681,9 @@ void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, v WaitDialogDisplaying = FALSE; + + if (!(hwnd && bUseHwndAsParent)) + { + if (hParent) + DestroyWindow (hParent); + UnregisterClassW (className, hInst); + } } |