//实现窗体鼠标穿透 public const int GWL_EXSTYLE = -20; public const uint WS_EX_LAYERED = 0x80000; public const int WS_EX_TRANSPARENT = 0x20; public const int LWA_ALPHA = 0x2; [DllImport("user32", EntryPoint = "SetWindowLong")] public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);[DllImport("user32", EntryPoint = "GetWindowLong")] public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);[DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")] public static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, int bAlpha, int dwFlags); //实现代码 GetWindowLong(this.Handle, GWL_EXSTYLE); SetWindowLong(this.Handle, GWL_EXSTYLE, intExTemp | WS_EX_TRANSPARENT | WS_EX_LAYERED); SetLayeredWindowAttributes(this.Handle, 0, 100, LWA_ALPHA);
或者就是一个全屏的窗体.
期间把程序最小化 和还原夹在发消息中间,程序隐藏和显示执行的速度很快 用户是看不出来的这里只提供思想
TransparencyKey = BackColor;
期间把程序最小化 和还原夹在发消息中间,程序隐藏和显示执行的速度很快 用户是看不出来的 这里只提供思想
还有WINDOWS任务管理器里面的选项-前端显示的功能。
这个应该是windows 的API里面有吧,不知道调用哪个,查一下吧
唯一差别就是,把 WM_LBUTTONDBLCLICK 发送给 explorer.exe
而不是发给父窗口。
//实现窗体鼠标穿透
public const int GWL_EXSTYLE = -20;
public const uint WS_EX_LAYERED = 0x80000;
public const int WS_EX_TRANSPARENT = 0x20;
public const int LWA_ALPHA = 0x2;
[DllImport("user32", EntryPoint = "SetWindowLong")]
public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);[DllImport("user32", EntryPoint = "GetWindowLong")]
public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);[DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")]
public static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, int bAlpha, int dwFlags);
//实现代码
GetWindowLong(this.Handle, GWL_EXSTYLE);
SetWindowLong(this.Handle, GWL_EXSTYLE, intExTemp | WS_EX_TRANSPARENT | WS_EX_LAYERED);
SetLayeredWindowAttributes(this.Handle, 0, 100, LWA_ALPHA);