diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp b/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp index cf879955..0535f673 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp +++ b/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020, David Xanatos + * Copyright (c) 2020-2022, David Xanatos * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -53,6 +53,8 @@ const WCHAR *Sandboxie_WindowClassName = L"Sandboxie_BorderWindow"; CBoxBorder::CBoxBorder(CSbieAPI* pApi, QObject* parent) : QThread(parent) { + m = NULL; + m_Api = pApi; m_Running = true; @@ -186,6 +188,7 @@ void CBoxBorder::run() m->ActiveWnd = NULL; m->ActivePid = 0; + hide: if (m->IsBorderVisible) { ::ShowWindow(m->BorderWnd, SW_HIDE); @@ -199,35 +202,31 @@ void CBoxBorder::run() if (NothingChanged(hWnd, &rect, pid)) continue; - if (m->IsBorderVisible) - ::ShowWindow(m->BorderWnd, SW_HIDE); - m->IsBorderVisible = FALSE; - m->ActiveWnd = hWnd; m->ActivePid = pid; memcpy(&m->ActiveRect, &rect, sizeof(RECT)); m->TitleState = 0; if (rect.right - rect.left <= 2 || rect.bottom - rect.top <= 2) - continue; + goto hide; HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL); if (!hMonitor) - continue; + goto hide; MONITORINFO Monitor; memset(&Monitor, 0, sizeof(MONITORINFO)); Monitor.cbSize = sizeof(MONITORINFO); if (!GetMonitorInfo(hMonitor, &Monitor)) - continue; + goto hide; const RECT *Desktop = &Monitor.rcMonitor; - if (rect.left <= Desktop->left && rect.top <= Desktop->top && + if (rect.left <= Desktop->left && rect.top <= Desktop->top && rect.right >= Desktop->right && rect.bottom >= Desktop->bottom && (Style & WS_CAPTION) != WS_CAPTION) - continue; + goto hide; if (m->BorderMode == 2) { if(!IsMounseOnTitle(hWnd, &rect, Desktop)) - continue; + goto hide; } @@ -261,7 +260,6 @@ void CBoxBorder::run() if (rect.bottom == Monitor.rcWork.bottom) ah -= 1; - POINT Points[10]; int PointCount = 0; @@ -282,8 +280,9 @@ void CBoxBorder::run() HRGN hrgn = CreatePolygonRgn(Points, PointCount, ALTERNATE); SetWindowRgn(m->BorderWnd, hrgn, TRUE); - SetWindowPos(m->BorderWnd, NULL, ax, ay, aw, ah, SWP_SHOWWINDOW | SWP_NOACTIVATE); + DeleteObject(hrgn); + SetWindowPos(m->BorderWnd, NULL, ax, ay, aw, ah, SWP_SHOWWINDOW | SWP_NOACTIVATE); m->IsBorderVisible = TRUE; } } @@ -296,6 +295,7 @@ void CBoxBorder::run() } delete m; + m = NULL; } diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.h b/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.h index cbb50eb1..6cd681f4 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.h +++ b/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020, David Xanatos + * Copyright (c) 2020-2022, David Xanatos * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index e3ef974a..23d5f4a4 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -741,7 +741,7 @@ void CSettingsWindow::OnTab() QSharedPointer pTemplate = QSharedPointer(new CSbieIni("Template_" + I.key(), theAPI)); - QString Title = pTemplate->GetText("Tmpl.Title"); + QString Title = pTemplate->GetText("Tmpl.Title", "", false, true, true); if (Title.left(1) == "#") { int End = Title.mid(1).indexOf(",");