LunarPresentation/AeroGlassClass.cs
(完整代码) 1KBusing System;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows.Media;
namespace SHomeWorkshop.LunarPresentation.AeroGlassLib
{
public struct MARGINS
{
public MARGINS(int i)
{
Left = i;
Right = i;
Top = i;
Bottom = i;
}
public MARGINS(int left, int top, int right, int bottom)
{
Left = left; Top = top; Right = right; Bottom = bottom;
}
public int Left;
public int Right;
public int Top;
public int Bottom;
}
public class AeroGlassForWPFWindow
{
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern void DwmExtendFrameIntoClientArea(
IntPtr hWnd, ref MARGINS pMarInset);
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern bool DwmIsCompositionEnabled();
public static bool ExtendGlassFrame(System.Windows.Window window, MARGINS margin)
{
if (!DwmIsCompositionEnabled())
return false;
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (hwnd == IntPtr.Zero)
throw new InvalidOperationException(
"应用玻璃窗口特效之前要先显示窗口!");
window.Background = System.Windows.Media.Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS refMargin = margin;
DwmExtendFrameIntoClientArea(hwnd, ref refMargin);
return true;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。