diff --git a/qframelesswindow/windows/__init__.py b/qframelesswindow/windows/__init__.py index 8f3c55f..56c9e53 100644 --- a/qframelesswindow/windows/__init__.py +++ b/qframelesswindow/windows/__init__.py @@ -209,8 +209,6 @@ def updateFrameless(self): self.windowEffect.addWindowAnimation(self.winId()) self.windowEffect.setAcrylicEffect(self.winId()) - if win_utils.isGreaterEqualWin11(): - self.windowEffect.addShadowEffect(self.winId()) def nativeEvent(self, eventType, message): """ Handle the Windows message """ diff --git a/qframelesswindow/windows/window_effect.py b/qframelesswindow/windows/window_effect.py index 307bd5e..d2653c2 100644 --- a/qframelesswindow/windows/window_effect.py +++ b/qframelesswindow/windows/window_effect.py @@ -12,7 +12,7 @@ DWMWINDOWATTRIBUTE, MARGINS, WINDOWCOMPOSITIONATTRIB, WINDOWCOMPOSITIONATTRIBDATA, DWM_BLURBEHIND) -from ..utils.win32_utils import isGreaterEqualWin10, isGreaterEqualWin11, isCompositionEnabled +from ..utils.win32_utils import isGreaterEqualWin10, isGreaterEqualWin11, isCompositionEnabled, isWin7 class WindowsWindowEffect: @@ -71,6 +71,8 @@ def setAcrylicEffect(self, hWnd, gradientColor="F2F2F299", enableShadow=True, an return hWnd = int(hWnd) + margins = MARGINS(-1, -1, -1, -1) + self.DwmExtendFrameIntoClientArea(hWnd, byref(margins)) gradientColor = ''.join(gradientColor[i:i+2] for i in range(6, -1, -2)) gradientColor = DWORD(int(gradientColor, base=16)) animationId = DWORD(animationId) @@ -128,9 +130,13 @@ def setAeroEffect(self, hWnd): Window handle """ hWnd = int(hWnd) - self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value - self.accentPolicy.AccentState = ACCENT_STATE.ACCENT_ENABLE_BLURBEHIND.value - self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData)) + if isWin7(): + margins = MARGINS(-1, -1, -1, -1) + self.DwmExtendFrameIntoClientArea(hWnd, byref(margins)) + else: + self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value + self.accentPolicy.AccentState = ACCENT_STATE.ACCENT_ENABLE_BLURBEHIND.value + self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData)) def removeBackgroundEffect(self, hWnd): """ Remove background effect @@ -141,6 +147,8 @@ def removeBackgroundEffect(self, hWnd): Window handle """ hWnd = int(hWnd) + margins = MARGINS(1, 0, 0, 0) + self.DwmExtendFrameIntoClientArea(hWnd, byref(margins)) self.accentPolicy.AccentState = ACCENT_STATE.ACCENT_DISABLED.value self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData)) @@ -171,7 +179,7 @@ def addShadowEffect(self, hWnd): return hWnd = int(hWnd) - margins = MARGINS(-1, -1, -1, -1) + margins = MARGINS(1, 0, 0, 0) self.DwmExtendFrameIntoClientArea(hWnd, byref(margins)) def addMenuShadowEffect(self, hWnd): @@ -204,12 +212,16 @@ def removeShadowEffect(self, hWnd): Window handle """ hWnd = int(hWnd) - self.DwmSetWindowAttribute( - hWnd, - DWMWINDOWATTRIBUTE.DWMWA_NCRENDERING_POLICY.value, - byref(c_int(DWMNCRENDERINGPOLICY.DWMNCRP_DISABLED.value)), - 4, - ) + if isWin7(): + margins = MARGINS(0, 0, 0, 0) + self.DwmExtendFrameIntoClientArea(hWnd, byref(margins)) + else: + self.DwmSetWindowAttribute( + hWnd, + DWMWINDOWATTRIBUTE.DWMWA_NCRENDERING_POLICY.value, + byref(c_int(DWMNCRENDERINGPOLICY.DWMNCRP_DISABLED.value)), + 4, + ) @staticmethod def removeMenuShadowEffect(hWnd):