不废话给代码:
c#类 记住 在引用添加 using Microsoft.WindowsAPICodePack.Shell; 需要 WindowsAPICodePack 类库 没有就 联系 我QQ 277800852 我给你发 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Media;
using Microsoft.WindowsAPICodePack.Shell;
using Dedom;
namespace Dedom
{
public static class MainWindows
{
#region 对窗体进行玻璃窗的扩展方法
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
};
[DllImport("DwmApi.dll")]
public static extern int DwmExtendFrameIntoClientArea(
IntPtr hwnd,
ref MARGINS pMarInset);
public class Win32Native
{
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetParent")]
public extern static IntPtr SetParent(IntPtr childPtr, IntPtr parentPtr);
}
}
#endregion
}
然后直接在 WPF 窗体 调用
this.Background = Brushes.Transparent;
MainWindows.ExtendAeroGlass(this);