Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Common/Dlgcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -9145,6 +9145,7 @@ void ShowWaitDialogEx(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback,
{
/* create invisible window and use it as parent */
WNDCLASSEXW winClass;
int parentX = 0, parentY = 0;

memset (&winClass, 0, sizeof (winClass));
winClass.cbSize = sizeof (WNDCLASSEX);
Expand All @@ -9153,7 +9154,21 @@ void ShowWaitDialogEx(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback,
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);
/* Place the invisible parent at the center of the creator window so that
the DS_CENTER wait dialog is centered on the monitor that hosts the main
window instead of always appearing on the primary monitor. Falls back to
(0, 0) when the creator window is unavailable, hidden or minimized. */
if (creatorWnd && IsWindowVisible (creatorWnd) && !IsIconic (creatorWnd))
{
RECT rcCreator;
if (GetWindowRect (creatorWnd, &rcCreator))
{
parentX = rcCreator.left + (rcCreator.right - rcCreator.left) / 2;
parentY = rcCreator.top + (rcCreator.bottom - rcCreator.top) / 2;
}
}

hParent = CreateWindowExW (WS_EX_TOOLWINDOW | WS_EX_LAYERED, className, L"VeraCrypt ShowWaitDialog Parent", 0, parentX, parentY, 1, 1, NULL, NULL, hInst, NULL);
if (hParent)
{
SetLayeredWindowAttributes (hParent, 0, 1, LWA_ALPHA);
Expand Down
Loading