77import win32api
88import win32con
99import win32gui
10+ from PyQt5 .QtGui import QColor
1011
1112from .c_structures import (ACCENT_POLICY , ACCENT_STATE , DWMNCRENDERINGPOLICY ,
1213 DWMWINDOWATTRIBUTE , MARGINS ,
@@ -82,6 +83,44 @@ def setAcrylicEffect(self, hWnd, gradientColor="F2F2F299", enableShadow=True, an
8283 self .winCompAttrData .Attribute = WINDOWCOMPOSITIONATTRIB .WCA_ACCENT_POLICY .value
8384 self .SetWindowCompositionAttribute (hWnd , pointer (self .winCompAttrData ))
8485
86+ def setBorderAccentColor (self , hWnd , color : QColor ):
87+ """ Set the border color of the window
88+
89+ Parameters
90+ ----------
91+ hWnd: int or `sip.voidptr`
92+ Window handle
93+
94+ color: QColor
95+ Border Accent color
96+ """
97+ if not isGreaterEqualWin11 ():
98+ return
99+
100+ hWnd = int (hWnd )
101+ colorref = DWORD (color .red () | (color .green () << 8 ) | (color .blue () << 16 ))
102+ self .DwmSetWindowAttribute (hWnd ,
103+ DWMWINDOWATTRIBUTE .DWMWA_BORDER_COLOR .value ,
104+ byref (colorref ),
105+ 4 )
106+
107+ def removeBorderAccentColor (self , hWnd ):
108+ """ Remove the border color of the window
109+
110+ Parameters
111+ ----------
112+ hWnd: int or `sip.voidptr`
113+ Window handle
114+ """
115+ if not isGreaterEqualWin11 ():
116+ return
117+
118+ hWnd = int (hWnd )
119+ self .DwmSetWindowAttribute (hWnd ,
120+ DWMWINDOWATTRIBUTE .DWMWA_BORDER_COLOR .value ,
121+ byref (DWORD (0xFFFFFFFF )),
122+ 4 )
123+
85124 def setMicaEffect (self , hWnd , isDarkMode = False , isAlt = False ):
86125 """ Add the mica effect to the window (Win11 only)
87126
@@ -101,7 +140,8 @@ def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
101140 return
102141
103142 hWnd = int (hWnd )
104- margins = MARGINS (- 1 , - 1 , - 1 , - 1 )
143+ # fix issue #125
144+ margins = MARGINS (16777215 , 16777215 , 0 , 0 )
105145 self .DwmExtendFrameIntoClientArea (hWnd , byref (margins ))
106146
107147 self .winCompAttrData .Attribute = WINDOWCOMPOSITIONATTRIB .WCA_ACCENT_POLICY .value
@@ -115,9 +155,9 @@ def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
115155 if sys .getwindowsversion ().build < 22523 :
116156 self .DwmSetWindowAttribute (hWnd , 1029 , byref (c_int (1 )), 4 )
117157 else :
118- self .DwmSetWindowAttribute (hWnd , 38 , byref (c_int (4 if isAlt else 2 )), 4 )
158+ self .DwmSetWindowAttribute (hWnd , DWMWINDOWATTRIBUTE . DWMWA_SYSTEMBACKDROP_TYPE . value , byref (c_int (4 if isAlt else 2 )), 4 )
119159
120- self .DwmSetWindowAttribute (hWnd , 20 , byref (c_int (1 * isDarkMode )), 4 )
160+ self .DwmSetWindowAttribute (hWnd , DWMWINDOWATTRIBUTE . DWMWA_USE_IMMERSIVE_DARK_MODE . value , byref (c_int (1 * isDarkMode )), 4 )
121161
122162 def setAeroEffect (self , hWnd ):
123163 """ Add the aero effect to the window
0 commit comments