I want to make a splash screen, which cannot be clicked/selected by mouse/UI.
As such how to I apply
Win32.ExtendedWindowStyles.WS_EX_TRANSPARENT
on Windows Presentation Foundation Window?
I want to make a splash screen, which cannot be clicked/selected by mouse/UI.
As such how to I apply
Win32.ExtendedWindowStyles.WS_EX_TRANSPARENT
on Windows Presentation Foundation Window?
public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hwnd, int index);
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
public static void ToTransparentWindow(this Window x)
{
x.SourceInitialized +=
delegate
{
// Get this window's handle
IntPtr hwnd = new WindowInteropHelper(x).Handle;
// Change the extended window style to include WS_EX_TRANSPARENT
int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
};
}
You can use a forms host to host a win form if you really want, then you can use anything win forms related in WPF.
But keep in mind WPF is built on direct X. However, there is already a splash screen class that is not based on WPF and will render while the .Net runtime does its thing. To my knowledge it doesn't have the same routed event pipeline that WPF windows have. You might try looking there before going down the forms host route.
in Win32 Api you can assign style on CreateWindow(Ex) or later by using SetWindowLong maybe there is some kinfd of wrapper on WPF