小编Lar*_*187的帖子

如何在WPF中使鼠标事件对窗口不可见?

我创建了这个类,它完美地使我的WPF应用程序对鼠标事件透明.

using System.Runtime.InteropServices;

class Win32

{
    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 makeTransparent(IntPtr hwnd)
    {
        // Change the extended window style to include WS_EX_TRANSPARENT
        int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
        Win32.SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);    
    }

    public static void makeNormal(IntPtr hwnd)
    {
      //how back to normal what is the code ?

    } …
Run Code Online (Sandbox Code Playgroud)

c# wpf events mouseevent

5
推荐指数
1
解决办法
3229
查看次数

标签 统计

c# ×1

events ×1

mouseevent ×1

wpf ×1