[FancyZones]Window transparency error fix (#19134)

This commit is contained in:
Seraphima Zykova 2022-07-01 18:24:16 +02:00 committed by GitHub
parent d201ae4335
commit 0c238a8eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -375,20 +375,22 @@ void WindowMoveHandler::SetWindowTransparency(HWND window) noexcept
if (FancyZonesSettings::settings().makeDraggedWindowTransparent) if (FancyZonesSettings::settings().makeDraggedWindowTransparent)
{ {
m_windowTransparencyProperties.draggedWindowExstyle = GetWindowLong(window, GWL_EXSTYLE); m_windowTransparencyProperties.draggedWindowExstyle = GetWindowLong(window, GWL_EXSTYLE);
m_windowTransparencyProperties.draggedWindow = window;
SetWindowLong(window, SetWindowLong(window,
GWL_EXSTYLE, GWL_EXSTYLE,
m_windowTransparencyProperties.draggedWindowExstyle | WS_EX_LAYERED); m_windowTransparencyProperties.draggedWindowExstyle | WS_EX_LAYERED);
if (!GetLayeredWindowAttributes(window, &m_windowTransparencyProperties.draggedWindowCrKey, &m_windowTransparencyProperties.draggedWindowInitialAlpha, &m_windowTransparencyProperties.draggedWindowDwFlags)) if (!GetLayeredWindowAttributes(window, &m_windowTransparencyProperties.draggedWindowCrKey, &m_windowTransparencyProperties.draggedWindowInitialAlpha, &m_windowTransparencyProperties.draggedWindowDwFlags))
{ {
Logger::error(L"SetWindowTransparency: GetLayeredWindowAttributes failed, {}", get_last_error_or_default(GetLastError())); Logger::error(L"Window transparency: GetLayeredWindowAttributes failed, {}", get_last_error_or_default(GetLastError()));
return;
} }
m_windowTransparencyProperties.draggedWindow = window;
if (!SetLayeredWindowAttributes(window, 0, (255 * 50) / 100, LWA_ALPHA)) if (!SetLayeredWindowAttributes(window, 0, (255 * 50) / 100, LWA_ALPHA))
{ {
Logger::error(L"SetWindowTransparency: SetLayeredWindowAttributes failed, {}", get_last_error_or_default(GetLastError())); Logger::error(L"Window transparency: SetLayeredWindowAttributes failed, {}", get_last_error_or_default(GetLastError()));
} }
} }
} }
@ -399,12 +401,12 @@ void WindowMoveHandler::ResetWindowTransparency() noexcept
{ {
if (!SetLayeredWindowAttributes(m_windowTransparencyProperties.draggedWindow, m_windowTransparencyProperties.draggedWindowCrKey, m_windowTransparencyProperties.draggedWindowInitialAlpha, m_windowTransparencyProperties.draggedWindowDwFlags)) if (!SetLayeredWindowAttributes(m_windowTransparencyProperties.draggedWindow, m_windowTransparencyProperties.draggedWindowCrKey, m_windowTransparencyProperties.draggedWindowInitialAlpha, m_windowTransparencyProperties.draggedWindowDwFlags))
{ {
Logger::error(L"ResetWindowTransparency: SetLayeredWindowAttributes failed"); Logger::error(L"Window transparency: SetLayeredWindowAttributes failed");
} }
if (SetWindowLong(m_windowTransparencyProperties.draggedWindow, GWL_EXSTYLE, m_windowTransparencyProperties.draggedWindowExstyle) == 0) if (SetWindowLong(m_windowTransparencyProperties.draggedWindow, GWL_EXSTYLE, m_windowTransparencyProperties.draggedWindowExstyle) == 0)
{ {
Logger::error(L"ResetWindowTransparency: SetWindowLong failed, {}", get_last_error_or_default(GetLastError())); Logger::error(L"Window transparency: SetWindowLong failed, {}", get_last_error_or_default(GetLastError()));
} }
m_windowTransparencyProperties.draggedWindow = nullptr; m_windowTransparencyProperties.draggedWindow = nullptr;