我创建了这个类,它完美地使我的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 ?
}
}
我运行这个代码来忽略鼠标事件,但执行完之后,我希望应用程序能够恢复正常并再次处理鼠标事件。该怎么做?
IntPtr hwnd = new WindowInteropHelper(this).Handle;
Win32.makeTransparent(hwnd);
如何编写代码使应用程序恢复正常?
~
,而不是一个!
——它们在键盘上太接近了。 - Cody Gray