File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1- using Microsoft . UI . Composition ;
1+ using Microsoft . UI . Composition ;
22using Microsoft . UI . Xaml ;
33using Microsoft . UI . Xaml . Hosting ;
44using System ;
@@ -85,6 +85,9 @@ protected override void OnTargetDisconnected(ICompositionSupportsSystemBackdrop
8585 backdrop ? . Dispose ( ) ;
8686 brush ? . Dispose ( ) ;
8787 brush = null ;
88+ if ( ! backgroundBrush . IsNull )
89+ PInvoke . DeleteObject ( backgroundBrush ) ;
90+ backgroundBrush = Windows . Win32 . Graphics . Gdi . HBRUSH . Null ;
8891 base . OnTargetDisconnected ( disconnectedTarget ) ;
8992 }
9093
@@ -100,12 +103,15 @@ private static void ConfigureDwm(ulong hWnd)
100103 } ) ;
101104 }
102105
106+ private Windows . Win32 . Graphics . Gdi . HBRUSH backgroundBrush = Windows . Win32 . Graphics . Gdi . HBRUSH . Null ;
107+
103108 private bool ClearBackground ( nint hwnd , nint hdc )
104109 {
105110 if ( PInvoke . GetClientRect ( new Windows . Win32 . Foundation . HWND ( hwnd ) , out var rect ) )
106111 {
107- var brush = PInvoke . CreateSolidBrush ( new Windows . Win32 . Foundation . COLORREF ( 0 ) ) ;
108- FillRect ( hdc , ref rect , brush ) ;
112+ if ( backgroundBrush . IsNull )
113+ backgroundBrush = PInvoke . CreateSolidBrush ( new Windows . Win32 . Foundation . COLORREF ( 0 ) ) ;
114+ FillRect ( hdc , ref rect , backgroundBrush ) ;
109115 return true ;
110116 }
111117 return false ;
You can’t perform that action at this time.
0 commit comments