/// <summary> /// Allows the SDL2Window to become transparent. /// </summary> /// <param name="handle"> /// Veldrid window handle in IntPtr format. /// </param> internal static void InitTransparency(IntPtr handle) { GWL_EXSTYLE_CLICKABLE = GetWindowLongPtr(handle, GWL_EXSTYLE); GWL_EXSTYLE_NOT_CLICKABLE = new IntPtr( GWL_EXSTYLE_CLICKABLE.ToInt64() | WS_EX_LAYERED | WS_EX_TRANSPARENT); Margins margins = Margins.FromRectangle(new Rectangle(-1, -1, -1, -1)); DwmExtendFrameIntoClientArea(handle, ref margins); }
public static void EnableTransparent(IntPtr handle, Rectangle size) { int windowLong = GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT; SetWindowLong(handle, GWL_EXSTYLE, new IntPtr(windowLong)); SetLayeredWindowAttributes(handle, 0, 255, LWA_ALPHA); Margins margins = Margins.FromRectangle(size); DwmExtendFrameIntoClientArea(handle, ref margins); }
public static void EnableTransparentByColorRef(IntPtr handle, Rectangle size, int color) { var windowLong = GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_LAYERED; SetWindowLong(handle, GWL_EXSTYLE, new IntPtr(windowLong)); SetLayeredWindowAttributes(handle, (uint)color, 100, LWA_ALPHA | LWA_COLORKEY); var margins = Margins.FromRectangle(size); DwmExtendFrameIntoClientArea(handle, ref margins); }
/// <summary> /// Allows the SDL2Window to become transparent. /// </summary> /// <param name="handle"> /// Veldrid window handle in IntPtr format. /// </param> /// <param name="size"> /// Size of the SDL2Window. /// </param> public static void EnableTransparent(IntPtr handle, Rectangle size) { IntPtr windowLong = GetWindowLongPtr(handle, GWL_EXSTYLE); windowLong = new IntPtr(windowLong.ToInt64() | WS_EX_LAYERED | WS_EX_TRANSPARENT); SetWindowLongPtr(handle, GWL_EXSTYLE, windowLong); Margins margins = Margins.FromRectangle(size); DwmExtendFrameIntoClientArea(handle, ref margins); }