File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Samples/Islands/WpfCalculator/CalculatorDemo Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ protected override HandleRef BuildWindowCore(HandleRef hwndParent)
20
20
_compositor ,
21
21
new Microsoft . UI . WindowId ( ( ulong ) hwndParent . Handle ) ) ;
22
22
23
+ // Mark as a layered window to handle transparent HWND with WPF.
24
+ var hwndChild = Win32Interop . GetWindowFromWindowId ( DesktopChildSiteBridge . WindowId ) ;
25
+ int prevExStyleFlags = GetWindowLong ( hwndChild , GWL_EXSTYLE ) ;
26
+ SetWindowLongPtr (
27
+ hwndChild ,
28
+ GWL_EXSTYLE ,
29
+ new IntPtr ( prevExStyleFlags | WS_EX_LAYERED ) ) ;
30
+
23
31
return new HandleRef ( null , ( nint ) DesktopChildSiteBridge . WindowId . Value ) ;
24
32
}
25
33
@@ -30,5 +38,22 @@ protected override void DestroyWindowCore(HandleRef hwnd)
30
38
}
31
39
32
40
Microsoft . UI . Composition . Compositor _compositor ;
41
+
42
+ #region P/Invokes
43
+ const int GWL_EXSTYLE = - 20 ;
44
+ const int WS_EX_LAYERED = 0x00080000 ;
45
+
46
+ [ DllImport ( "user32.dll" ) ]
47
+ static extern int GetWindowLong (
48
+ IntPtr hwnd ,
49
+ int index ) ;
50
+
51
+ [ DllImport ( "user32.dll" , EntryPoint = "SetWindowLongPtr" ) ]
52
+ [ return : MarshalAs ( UnmanagedType . Bool ) ]
53
+ public static extern bool SetWindowLongPtr (
54
+ IntPtr hWnd ,
55
+ int nIndex ,
56
+ IntPtr dwNewLong ) ;
57
+ #endregion
33
58
}
34
- }
59
+ }
You can’t perform that action at this time.
0 commit comments