I had posted a way with a SwapChainPanel
From some people who had tested, the border + shadow were on Windows 11 and I added DwmSetWindowAttribute at beginning to remove them
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi, i want to make a transparent window, i used following codes:
public static void SetTransparent(Window window, bool isTransparent)
{
var rgn = NativeMethods.CreateRectRgn(-2, -2, -1, -1);
var dmw = new NativeValues.DWM_BLURBEHIND()
{
dwFlags = NativeValues.DWM_BLURBEHIND_Mask.DWM_BB_ENABLE | NativeValues.DWM_BLURBEHIND_Mask.DWM_BB_BLURREGION,
fEnable = true,
hRgnBlur = rgn,
};
NativeMethods.DwmEnableBlurBehindWindow(WindowNative.GetWindowHandle(window), ref dmw);
ICompositionSupportsSystemBackdrop brushHolder = window.As<ICompositionSupportsSystemBackdrop>();
if (isTransparent)
{
var colorBrush = WindowsCompositionHelper.Compositor.CreateColorBrush(Windows.UI.Color.FromArgb(0, 255, 255, 255));
brushHolder.SystemBackdrop = colorBrush;
}
else
{
brushHolder.SystemBackdrop = null;
}
}
but there is some issues:
if windows theme is Dark, window will be transparent with a border/frame + shadow around window
if windows theme is Light, window can not be transparent and a white background will be shown
so there is 3 issue:
first, transparent window should work in Light and Dark theme
second, how to remove border when window is transparent?
third, can we get fully transparent window? i mean i can access anything under window. for example if explorer is open and transparent window is opened on explorer i can access explorer from transparent window.
I had posted a way with a SwapChainPanel
From some people who had tested, the border + shadow were on Windows 11 and I added DwmSetWindowAttribute at beginning to remove them