小白一枚。。最近在做一个音乐播放器,做了个桌面歌词,需要鼠标穿透,通过网上找的代码已经实现,但是在不重新绘制窗口的情况下如何取消穿透??下面是代码
在窗口创建完时执行下面这个代码实现穿透
SourceInitialized += delegate
{
IntPtr hwnd = new WindowInteropHelper(this).Handle;
uint extendedStyle = GetWindowLong(hwnd, GwlExstyle);
SetWindowLong(hwnd, GwlExstyle, extendedStyle | WsExTransparent);
};
private const int WsExTransparent = 0x20;
private const int GwlExstyle = (-20);
[DllImport("user32", EntryPoint = "SetWindowLong")]
private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
[DllImport("user32", EntryPoint = "GetWindowLong")]
private static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
怎么取消穿透呢