zoukankan      html  css  js  c++  java
  • wpf 透明效果 需要DwmApi.dll文件,然后定义一个函数去画Aero区域,从而实现整个窗口的Aero化。

    private void ExtendAeroGlass(Window window)
    {
    try
    {
    // 为WPF程序获取窗口句柄
    IntPtr mainWindowPtr = new WindowInteropHelper(window).Handle;
    HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
    mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent;

    // 设置Margins
    MARGINS margins = new MARGINS();

    // 扩展Aero Glass
    margins.cxLeftWidth = -1;
    margins.cxRightWidth = -1;
    margins.cyTopHeight = -1;
    margins.cyBottomHeight = -1;

    int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
    if (hr < 0)
    {
    MessageBox.Show("DwmExtendFrameIntoClientArea Failed");
    }
    }
    catch (DllNotFoundException)
    {
    Application.Current.MainWindow.Background = Brushes.White;
    }
    }

    [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);

    至少证明我们还活着
  • 相关阅读:
    JAVA进阶17
    JAVA进阶16
    Map in C++ Standard Template Library (STL)
    数据结构入门
    Day 17:Python 对象的相等性比较
    cmd of windows
    Nmap扫描工具
    Day16: python生产列表的使用方法
    Day 15:一些数据分析、机器学习和深度学习包和框架&&入门案例
    端口
  • 原文地址:https://www.cnblogs.com/pengde/p/5822010.html
Copyright © 2011-2022 走看看