#region 窗体鼠标穿透
private const uint WS_EX_LAYERED = 0x80000;
private const int WS_EX_TRANSPARENT = 0x20;
private const int GWL_STYLE = (-16);
private const int GWL_EXSTYLE = (-20);
private const int LWA_ALPHA = 0;
[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
);
[DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")]
private static extern int SetLayeredWindowAttributes(
IntPtr hwnd,
int crKey,
int bAlpha,
int dwFlags
);
/// <summary>
/// 声明委托类
/
C#-窗体鼠标穿透
最新推荐文章于 2022-08-12 10:56:36 发布
本文档介绍如何在C#中实现窗体的鼠标穿透效果,通过设置窗体的WS_EX_TRANSPARENT和WS_EX_LAYERED风格,并使用SetWindowLong、GetWindowLong和SetLayeredWindowAttributes等API函数,使窗体变得透明并允许鼠标穿透。
摘要由CSDN通过智能技术生成