Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WPF窗口上禁用hittesting?_C#_.net_Wpf_Window_Hittest - Fatal编程技术网

C# 如何在WPF窗口上禁用hittesting?

C# 如何在WPF窗口上禁用hittesting?,c#,.net,wpf,window,hittest,C#,.net,Wpf,Window,Hittest,我知道这是可能的——在创建窗口时,通过SetWindowLong API或WPF窗口类的托管属性。。。但我不知道如何做到这一点。我根本找不到有关如何设置窗口样式的信息,因此它无法接收有关鼠标单击它的任何系统消息,任何单击都会通过窗口到达底层窗口 有人知道这个样式代码吗?为窗口的扩展样式设置WS_EX_透明标志。它使窗口对鼠标单击透明 public const int WS_EX_TRANSPARENT = 0x00000020; public const int GWL_EXSTYLE = (-

我知道这是可能的——在创建窗口时,通过SetWindowLong API或WPF窗口类的托管属性。。。但我不知道如何做到这一点。我根本找不到有关如何设置窗口样式的信息,因此它无法接收有关鼠标单击它的任何系统消息,任何单击都会通过窗口到达底层窗口

有人知道这个样式代码吗?

为窗口的扩展样式设置WS_EX_透明标志。它使窗口对鼠标单击透明

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

int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
WinAPI.SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
为窗口的扩展样式设置WS_EX_透明标志。它使窗口对鼠标单击透明

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

int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
WinAPI.SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);

WS_EX_不够透明

需要WS_EX_透明| WS_EX_分层| WS_EX_顶层


WS_EX_不够透明

需要WS_EX_透明| WS_EX_分层| WS_EX_顶层


为什么不禁用窗口?@NikhilAgrawal你的意思是,将IsEnabled设置为false就行了?@NikhilAgrawal我试过了。该窗口仍然使用鼠标单击事件。我需要将事件传递到底层窗口。链接:。为什么不禁用窗口?@NikhilAgrawal你的意思是,将IsEnabled设置为false就可以了?@NikhilAgrawal我试过了。该窗口仍然使用鼠标单击事件。我需要将事件传递到基础windows。已链接:。这似乎足够了。赢8.1。看起来已经足够了。赢得8.1分。