csharp WPF鼠标穿透

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp WPF鼠标穿透相关的知识,希望对你有一定的参考价值。

    public const int WS_EX_TRANSPARENT = 0x00000020;    public const int GWL_EXSTYLE = (-20);        [DllImport("user32.dll")]    public static extern int GetWindowLong(IntPtr hwnd, int index);        [DllImport("user32.dll")]    public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);        public static void ToTransparentWindow(this Window x)    {      x.SourceInitialized +=        delegate        {            // Get this window's handle            IntPtr hwnd = new WindowInteropHelper(x).Handle;            // Change the extended window style to include WS_EX_TRANSPARENT            int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);        };    }

以上是关于csharp WPF鼠标穿透的主要内容,如果未能解决你的问题,请参考以下文章