zoukankan      html  css  js  c++  java
  • WPF Window 设置IsHitTestVisible="False" 但是还是不能透过窗口点击下方控件

    public static class WindowsServices
    {
      const int WS_EX_TRANSPARENT = 0x00000020;
      const int GWL_EXSTYLE = (-20);
    
      [DllImport("user32.dll")]
      static extern int GetWindowLong(IntPtr hwnd, int index);
    
      [DllImport("user32.dll")]
      static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
    
      public static void SetWindowExTransparent(IntPtr hwnd)
      {
        var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
        SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
      }
    }

    窗口增加

    protected override void OnSourceInitialized(EventArgs e)
    {
      base.OnSourceInitialized(e);
      var hwnd = new WindowInteropHelper(this).Handle;
      WindowsServices.SetWindowExTransparent(hwnd);
    }
  • 相关阅读:
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    将Ojective-C代码移植转换为Swift代码
    Swift
    房费制——报表(1)
  • 原文地址:https://www.cnblogs.com/abyss0303/p/10935967.html
Copyright © 2011-2022 走看看